-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c3ea70
commit 6035b84
Showing
43 changed files
with
524 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,55 @@ | ||
package app | ||
|
||
import "github.com/vseinstrumentiru/lego/v2/internal/execute" | ||
import ( | ||
"os" | ||
|
||
"emperror.dev/emperror" | ||
"github.com/spf13/cobra" | ||
"go.uber.org/dig" | ||
|
||
"github.com/vseinstrumentiru/lego/v2/config" | ||
di "github.com/vseinstrumentiru/lego/v2/internal/container" | ||
"github.com/vseinstrumentiru/lego/v2/internal/env" | ||
"github.com/vseinstrumentiru/lego/v2/version" | ||
) | ||
|
||
func rootCommand() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "lego", | ||
Hidden: true, | ||
} | ||
} | ||
|
||
func showVersion(e env.Env, c di.ChainContainer) { | ||
e.OnFlag("version", func(bool) { | ||
c.Execute(func(ver *version.Info) { ver.Print() }) | ||
os.Exit(0) | ||
}) | ||
} | ||
|
||
type cmdArgs struct { | ||
dig.In | ||
Root *cobra.Command | ||
Children []*cobra.Command `group:"cmd"` | ||
} | ||
|
||
func printDIGraph(e env.Env, c di.Container, cfg *config.Application) { | ||
if cfg.DebugMode { | ||
e.OnFlag("di", func(bool) { | ||
emperror.Panic(c.Visualize(os.Stdout)) | ||
os.Exit(0) | ||
}) | ||
} | ||
} | ||
|
||
func command(r *runtime) { | ||
r.container.Execute(execute.RunCommands) | ||
r.container.Execute(func(in cmdArgs) error { | ||
in.Root.AddCommand(in.Children...) | ||
cmds := in.Root.Commands() | ||
if len(cmds) > 0 { | ||
return in.Root.Execute() | ||
} | ||
|
||
return nil | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package netx | ||
|
||
import ( | ||
"net" | ||
|
||
"emperror.dev/errors" | ||
"github.com/cloudflare/tableflip" | ||
) | ||
|
||
func Listen(network, addr string, upg *tableflip.Upgrader) (net.Listener, error) { | ||
if upg != nil { | ||
return upg.Listen(network, addr) | ||
} | ||
|
||
ln, err := net.Listen(network, addr) | ||
|
||
return ln, errors.Wrap(err, "can't create new listener") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
package config | ||
|
||
const ( | ||
ServerMode = "server_mode" | ||
OptEnvPath = "opt_env_path" | ||
|
||
OptLocalDebug = "opt_local_debug" | ||
OptWithoutProviders = "opt_without_providers" | ||
OptEnvPath = "opt_env_path" | ||
OptLocalDebug = "opt_local_debug" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package di | ||
|
||
// Provider returns provider - function for registering provider and configurations - functions for configure it | ||
type Module func() (provider interface{}, configurations []interface{}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.