diff --git a/CHANGELOG.md b/CHANGELOG.md index dce08cf5db..1fdc65195a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,17 +7,26 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## 1.2.0 ### Added +- `skywire-cil visor hv` subcommand [#1390](https://github.com/skycoin/skywire/pull/1390) +- info field to Service struct [#1382](https://github.com/skycoin/skywire/pull/1382) - `skywire-cli` subcommand `arg` under `visor app` [#1356](https://github.com/skycoin/skywire/pull/1356) - `log_store` field to `transport` in config [#1386](https://github.com/skycoin/skywire/pull/1386) - `type`, `location`, `rotation_interval`, field to `log_store` inside `transport` in config [#1374](https://github.com/skycoin/skywire/pull/1374) - transport file logging to CSV [#1374](https://github.com/skycoin/skywire/pull/1374) - transport file logging to CSV [#1374](https://github.com/skycoin/skywire/pull/1374) +- `skywire-cli config priv` & `skywire-cli visor priv` subcommands and rpc [#1369](https://github.com/skycoin/skywire/issues/1369) - dmsghttp server [#1364](https://github.com/skycoin/skywire/issues/1364) ### Changed +- moved `skywire-cli visor` subcommands into `skywire-cil visor hv` [#1390](https://github.com/skycoin/skywire/pull/1390) +- use flags for `skywire-cli visor route` & `skywire-cli visor tp` [#1390](https://github.com/skycoin/skywire/pull/1390) - moved `skywire-cli` subcommand `autoconnect` from `visor app` to `visor app arg` [#1356](https://github.com/skycoin/skywire/pull/1356) -### Removed +### Fixed +- negative waitgroup [#1372](https://github.com/skycoin/skywire/pull/1372) +- absence of git in makefile [#1368](https://github.com/skycoin/skywire/pull/1368) +- rpc error in cli for json [#1367](https://github.com/skycoin/skywire/pull/1367) +- StartVPNCient logic [#1366](https://github.com/skycoin/skywire/pull/1366) ## 1.1.0 @@ -54,6 +63,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `skywire-cli visor tp add` flag `--public` [#1346](https://github.com/skycoin/skywire/pull/1346) - remove updater settings from UI +### Fixed +- UI update button [#1349](https://github.com/skycoin/skywire/pull/1349) + ## 1.0.0 ### Added diff --git a/cmd/skywire-cli/commands/mdisc/root.go b/cmd/skywire-cli/commands/mdisc/root.go index 8b49e2d5e9..b630369df9 100644 --- a/cmd/skywire-cli/commands/mdisc/root.go +++ b/cmd/skywire-cli/commands/mdisc/root.go @@ -25,7 +25,12 @@ var masterLogger = logging.NewMasterLogger() var packageLogger = masterLogger.PackageLogger("mdisc:disc") func init() { - RootCmd.PersistentFlags().StringVar(&mdAddr, "addr", utilenv.DmsgDiscAddr, "address of DMSG discovery server\n") + RootCmd.AddCommand( + entryCmd, + availableServersCmd, + ) + entryCmd.PersistentFlags().StringVar(&mdAddr, "addr", utilenv.DmsgDiscAddr, "address of DMSG discovery server\n") + availableServersCmd.PersistentFlags().StringVar(&mdAddr, "addr", utilenv.DmsgDiscAddr, "address of DMSG discovery server\n") var helpflag bool RootCmd.Flags().BoolVarP(&helpflag, "help", "h", false, "help for "+RootCmd.Use) RootCmd.Flags().MarkHidden("help") //nolint @@ -37,13 +42,6 @@ var RootCmd = &cobra.Command{ Short: "Query remote DMSG Discovery", } -func init() { - RootCmd.AddCommand( - entryCmd, - availableServersCmd, - ) -} - var entryCmd = &cobra.Command{ Use: "entry ", Short: "Fetch an entry", diff --git a/cmd/skywire-cli/commands/root.go b/cmd/skywire-cli/commands/root.go index 61b5bd93e0..dffd369014 100644 --- a/cmd/skywire-cli/commands/root.go +++ b/cmd/skywire-cli/commands/root.go @@ -12,7 +12,6 @@ import ( cliconfig "github.com/skycoin/skywire/cmd/skywire-cli/commands/config" clidmsgpty "github.com/skycoin/skywire/cmd/skywire-cli/commands/dmsgpty" climdisc "github.com/skycoin/skywire/cmd/skywire-cli/commands/mdisc" - clirpc "github.com/skycoin/skywire/cmd/skywire-cli/commands/rpc" clirtfind "github.com/skycoin/skywire/cmd/skywire-cli/commands/rtfind" clivisor "github.com/skycoin/skywire/cmd/skywire-cli/commands/visor" clivpn "github.com/skycoin/skywire/cmd/skywire-cli/commands/vpn" @@ -26,10 +25,11 @@ var rootCmd = &cobra.Command{ ┌─┐┬┌─┬ ┬┬ ┬┬┬─┐┌─┐ ┌─┐┬ ┬ └─┐├┴┐└┬┘││││├┬┘├┤───│ │ │ └─┘┴ ┴ ┴ └┴┘┴┴└─└─┘ └─┘┴─┘┴`, - SilenceErrors: true, - SilenceUsage: true, - DisableSuggestions: true, - Version: buildinfo.Version(), + SilenceErrors: true, + SilenceUsage: true, + DisableSuggestions: true, + DisableFlagsInUseLine: true, + Version: buildinfo.Version(), } func init() { @@ -42,12 +42,11 @@ func init() { climdisc.RootCmd, clicompletion.RootCmd, ) - - var helpflag bool var jsonOutput bool - - rootCmd.PersistentFlags().StringVar(&clirpc.Addr, "rpc", "localhost:3435", "RPC server address") rootCmd.PersistentFlags().BoolVar(&jsonOutput, internal.JSONString, false, "print output in json") + rootCmd.PersistentFlags().MarkHidden(internal.JSONString) //nolint + var helpflag bool + rootCmd.SetUsageTemplate(help) rootCmd.PersistentFlags().BoolVarP(&helpflag, "help", "h", false, "help for "+rootCmd.Use) rootCmd.SetHelpCommand(&cobra.Command{Hidden: true}) rootCmd.PersistentFlags().MarkHidden("help") //nolint @@ -68,8 +67,17 @@ func Execute() { NoExtraNewlines: true, NoBottomNewline: true, }) - if err := rootCmd.Execute(); err != nil { log.Fatal("Failed to execute command: ", err) } } + +const help = "Usage:\r\n" + + " {{.UseLine}}{{if .HasAvailableSubCommands}}{{end}} {{if gt (len .Aliases) 0}}\r\n\r\n" + + "{{.NameAndAliases}}{{end}}{{if .HasAvailableSubCommands}}\r\n\r\n" + + "Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand)}}\r\n " + + "{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}\r\n\r\n" + + "Flags:\r\n" + + "{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}\r\n\r\n" + + "Global Flags:\r\n" + + "{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}\r\n\r\n" diff --git a/cmd/skywire-cli/commands/rtfind/root.go b/cmd/skywire-cli/commands/rtfind/root.go index 2ef61ec35f..c0418e4377 100644 --- a/cmd/skywire-cli/commands/rtfind/root.go +++ b/cmd/skywire-cli/commands/rtfind/root.go @@ -21,10 +21,11 @@ var frMinHops, frMaxHops uint16 var timeout time.Duration func init() { - RootCmd.Flags().StringVarP(&frAddr, "addr", "a", utilenv.RouteFinderAddr, "route finder service address") + RootCmd.Flags().SortFlags = false RootCmd.Flags().Uint16VarP(&frMinHops, "min-hops", "n", 1, "minimum hops") RootCmd.Flags().Uint16VarP(&frMaxHops, "max-hops", "x", 1000, "maximum hops") RootCmd.Flags().DurationVarP(&timeout, "timeout", "t", 10*time.Second, "request timeout") + RootCmd.Flags().StringVarP(&frAddr, "addr", "a", utilenv.RouteFinderAddr, "route finder service address\n") var helpflag bool RootCmd.Flags().BoolVarP(&helpflag, "help", "h", false, "help for "+RootCmd.Use) RootCmd.Flags().MarkHidden("help") //nolint diff --git a/cmd/skywire-cli/commands/visor/app.go b/cmd/skywire-cli/commands/visor/app.go index 69eda956f4..fb71ff671d 100644 --- a/cmd/skywire-cli/commands/visor/app.go +++ b/cmd/skywire-cli/commands/visor/app.go @@ -42,11 +42,13 @@ var argCmd = &cobra.Command{ var appCmd = &cobra.Command{ Use: "app", Short: "App settings", + Long: "\n App settings", } var lsAppsCmd = &cobra.Command{ Use: "ls", Short: "List apps", + Long: "\n List apps", Run: func(cmd *cobra.Command, _ []string) { states, err := clirpc.Client(cmd.Flags()).Apps() internal.Catch(cmd.Flags(), err) @@ -92,6 +94,7 @@ var lsAppsCmd = &cobra.Command{ var startAppCmd = &cobra.Command{ Use: "start ", Short: "Launch app", + Long: "\n Launch app", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { internal.Catch(cmd.Flags(), clirpc.Client(cmd.Flags()).StartApp(args[0])) @@ -102,6 +105,7 @@ var startAppCmd = &cobra.Command{ var stopAppCmd = &cobra.Command{ Use: "stop ", Short: "Halt app", + Long: "\n Halt app", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { internal.Catch(cmd.Flags(), clirpc.Client(cmd.Flags()).StopApp(args[0])) @@ -131,6 +135,7 @@ var setAppAutostartCmd = &cobra.Command{ var setAppKillswitchCmd = &cobra.Command{ Use: "killswitch (true|false)", Short: "Set app killswitch", + Long: "\n Set app killswitch", Args: cobra.MinimumNArgs(2), Run: func(cmd *cobra.Command, args []string) { var killswitch bool @@ -150,6 +155,7 @@ var setAppKillswitchCmd = &cobra.Command{ var setAppSecureCmd = &cobra.Command{ Use: "secure (true|false)", Short: "Set app secure", + Long: "\n Set app secure", Args: cobra.MinimumNArgs(2), Run: func(cmd *cobra.Command, args []string) { var secure bool @@ -168,7 +174,8 @@ var setAppSecureCmd = &cobra.Command{ var setAppPasscodeCmd = &cobra.Command{ Use: "passcode ", - Short: "Set app passcode.\n \"remove\" is a special arg to remove the passcode", + Short: "Set app passcode", + Long: "\n Set app passcode.\n\r\n\r \"remove\" is a special arg to remove the passcode", Args: cobra.MinimumNArgs(2), Run: func(cmd *cobra.Command, args []string) { passcode := args[1] @@ -182,7 +189,8 @@ var setAppPasscodeCmd = &cobra.Command{ var setAppNetworkInterfaceCmd = &cobra.Command{ Use: "netifc ", - Short: "Set app network interface.\n \"remove\" is a special arg to remove the netifc", + Short: "Set app network interface", + Long: "Set app network interface.\n\r\n\r \"remove\" is a special arg to remove the netifc", Args: cobra.MinimumNArgs(2), Run: func(cmd *cobra.Command, args []string) { netifc := args[1] @@ -196,7 +204,8 @@ var setAppNetworkInterfaceCmd = &cobra.Command{ var appLogsSinceCmd = &cobra.Command{ Use: "log ", - Short: "Logs from app since RFC3339Nano-formatted timestamp.\n \"beginning\" is a special timestamp to fetch all the logs", + Short: "Logs from app", + Long: "\n Logs from app since RFC3339Nano-formatted timestamp.\n\r\n\r \"beginning\" is a special timestamp to fetch all the logs", Args: cobra.MinimumNArgs(2), Run: func(cmd *cobra.Command, args []string) { var t time.Time diff --git a/cmd/skywire-cli/commands/visor/exec.go b/cmd/skywire-cli/commands/visor/exec.go index 043f1a4226..bad8826b2f 100644 --- a/cmd/skywire-cli/commands/visor/exec.go +++ b/cmd/skywire-cli/commands/visor/exec.go @@ -18,6 +18,7 @@ func init() { var execCmd = &cobra.Command{ Use: "exec ", Short: "Execute a command", + Long: "\n Execute a command", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { out, err := clirpc.Client(cmd.Flags()).Exec(strings.Join(args, " ")) diff --git a/cmd/skywire-cli/commands/visor/hv.go b/cmd/skywire-cli/commands/visor/hv.go new file mode 100644 index 0000000000..3cee518f68 --- /dev/null +++ b/cmd/skywire-cli/commands/visor/hv.go @@ -0,0 +1,85 @@ +package clivisor + +import ( + "fmt" + + "github.com/spf13/cobra" + "github.com/toqueteos/webbrowser" + + "github.com/skycoin/skywire-utilities/pkg/cipher" + clirpc "github.com/skycoin/skywire/cmd/skywire-cli/commands/rpc" + "github.com/skycoin/skywire/cmd/skywire-cli/internal" + "github.com/skycoin/skywire/pkg/visor/visorconfig" +) + +func init() { + RootCmd.AddCommand(hvCmd) + hvCmd.AddCommand(hvuiCmd) + hvCmd.AddCommand(hvpkCmd) + hvpkCmd.Flags().StringVarP(&path, "input", "i", "", "path of input config file.") + hvpkCmd.Flags().BoolVarP(&pkg, "pkg", "p", false, "read from /opt/skywire/skywire.json") + hvpkCmd.Flags().BoolVarP(&web, "http", "w", false, "serve public key via http") + hvCmd.AddCommand(chvpkCmd) + +} + +var hvCmd = &cobra.Command{ + Use: "hv", + Short: "Hypervisor", + Long: "\n Hypervisor\n\r\n\r Access the hypervisor UI\n\r View remote hypervisor public key", +} + +var hvuiCmd = &cobra.Command{ + Use: "ui", + Short: "open Hypervisor UI in default browser", + Long: "\n open Hypervisor UI in default browser", + Run: func(_ *cobra.Command, _ []string) { + //TODO: get the actual port from config instead of using default value here + if err := webbrowser.Open("http://127.0.0.1:8000/"); err != nil { + logger.Fatal("Failed to open hypervisor UI in browser:", err) + } + }, +} + +var hvpkCmd = &cobra.Command{ + Use: "cpk", + Short: "Public key of remote hypervisor(s) set in config", + Long: "\n Public key of remote hypervisor(s) set in config", + Run: func(cmd *cobra.Command, _ []string) { + var hypervisors []cipher.PubKey + + if pkg { + path = visorconfig.Pkgpath + } + + if path != "" { + conf, err := visorconfig.ReadFile(path) + if err != nil { + internal.PrintFatalError(cmd.Flags(), fmt.Errorf("Failed to read config: %v", err)) + } + hypervisors = conf.Hypervisors + } else { + client := clirpc.Client(cmd.Flags()) + overview, err := client.Overview() + if err != nil { + internal.PrintFatalError(cmd.Flags(), fmt.Errorf("Failed to connect: %v", err)) + } + hypervisors = overview.Hypervisors + } + internal.PrintOutput(cmd.Flags(), hypervisors, fmt.Sprintf("%v\n", hypervisors)) + }, +} + +var chvpkCmd = &cobra.Command{ + Use: "pk", + Short: "Public key of remote hypervisor(s)", + Long: "Public key of remote hypervisor(s) which are currently connected to", + Run: func(cmd *cobra.Command, _ []string) { + client := clirpc.Client(cmd.Flags()) + overview, err := client.Overview() + if err != nil { + internal.PrintFatalError(cmd.Flags(), fmt.Errorf("Failed to connect: %v", err)) + } + internal.PrintOutput(cmd.Flags(), overview.ConnectedHypervisor, fmt.Sprintf("%v\n", overview.ConnectedHypervisor)) + }, +} diff --git a/cmd/skywire-cli/commands/visor/hvui.go b/cmd/skywire-cli/commands/visor/hvui.go deleted file mode 100644 index a8378cd26b..0000000000 --- a/cmd/skywire-cli/commands/visor/hvui.go +++ /dev/null @@ -1,21 +0,0 @@ -package clivisor - -import ( - "github.com/spf13/cobra" - "github.com/toqueteos/webbrowser" -) - -func init() { - RootCmd.AddCommand(hvuiCmd) -} - -var hvuiCmd = &cobra.Command{ - Use: "hvui", - Short: "Hypervisor UI", - Run: func(_ *cobra.Command, _ []string) { - //TODO: get the actual port from config instead of using default value here - if err := webbrowser.Open("http://127.0.0.1:8000/"); err != nil { - logger.Fatal("Failed to open hypervisor UI in browser:", err) - } - }, -} diff --git a/cmd/skywire-cli/commands/visor/info.go b/cmd/skywire-cli/commands/visor/info.go index 9b3bd58479..0fd5a3cc1a 100644 --- a/cmd/skywire-cli/commands/visor/info.go +++ b/cmd/skywire-cli/commands/visor/info.go @@ -7,7 +7,6 @@ import ( "github.com/spf13/cobra" - "github.com/skycoin/skywire-utilities/pkg/cipher" clirpc "github.com/skycoin/skywire/cmd/skywire-cli/commands/rpc" "github.com/skycoin/skywire/cmd/skywire-cli/internal" "github.com/skycoin/skywire/pkg/visor/visorconfig" @@ -25,11 +24,6 @@ func init() { pkCmd.Flags().BoolVarP(&pkg, "pkg", "p", false, "read from /opt/skywire/skywire.json") pkCmd.Flags().BoolVarP(&web, "http", "w", false, "serve public key via http") pkCmd.Flags().StringVarP(&webPort, "prt", "x", "7998", "serve public key via http") - RootCmd.AddCommand(hvpkCmd) - hvpkCmd.Flags().StringVarP(&path, "input", "i", "", "path of input config file.") - hvpkCmd.Flags().BoolVarP(&pkg, "pkg", "p", false, "read from /opt/skywire/skywire.json") - hvpkCmd.Flags().BoolVarP(&web, "http", "w", false, "serve public key via http") - RootCmd.AddCommand(chvpkCmd) RootCmd.AddCommand(summaryCmd) RootCmd.AddCommand(buildInfoCmd) } @@ -37,6 +31,7 @@ func init() { var pkCmd = &cobra.Command{ Use: "pk", Short: "Public key of the visor", + Long: "\n Public key of the visor", Run: func(cmd *cobra.Command, _ []string) { if pkg { path = visorconfig.Pkgpath @@ -66,50 +61,10 @@ var pkCmd = &cobra.Command{ }, } -var hvpkCmd = &cobra.Command{ - Use: "hvpk", - Short: "Public key of remote hypervisor", - Run: func(cmd *cobra.Command, _ []string) { - var hypervisors []cipher.PubKey - - if pkg { - path = visorconfig.Pkgpath - } - - if path != "" { - conf, err := visorconfig.ReadFile(path) - if err != nil { - internal.PrintFatalError(cmd.Flags(), fmt.Errorf("Failed to read config: %v", err)) - } - hypervisors = conf.Hypervisors - } else { - client := clirpc.Client(cmd.Flags()) - overview, err := client.Overview() - if err != nil { - internal.PrintFatalError(cmd.Flags(), fmt.Errorf("Failed to connect: %v", err)) - } - hypervisors = overview.Hypervisors - } - internal.PrintOutput(cmd.Flags(), hypervisors, fmt.Sprintf("%v\n", hypervisors)) - }, -} - -var chvpkCmd = &cobra.Command{ - Use: "chvpk", - Short: "Public key of connected hypervisors", - Run: func(cmd *cobra.Command, _ []string) { - client := clirpc.Client(cmd.Flags()) - overview, err := client.Overview() - if err != nil { - internal.PrintFatalError(cmd.Flags(), fmt.Errorf("Failed to connect: %v", err)) - } - internal.PrintOutput(cmd.Flags(), overview.ConnectedHypervisor, fmt.Sprintf("%v\n", overview.ConnectedHypervisor)) - }, -} - var summaryCmd = &cobra.Command{ Use: "info", Short: "Summary of visor info", + Long: "\n Summary of visor info", Run: func(cmd *cobra.Command, _ []string) { summary, err := clirpc.Client(cmd.Flags()).Summary() if err != nil { @@ -147,8 +102,9 @@ var summaryCmd = &cobra.Command{ } var buildInfoCmd = &cobra.Command{ - Use: "version", + Use: "ver", Short: "Version and build info", + Long: "\n Version and build info", Run: func(cmd *cobra.Command, _ []string) { client := clirpc.Client(cmd.Flags()) overview, err := client.Overview() diff --git a/cmd/skywire-cli/commands/visor/privacy.go b/cmd/skywire-cli/commands/visor/privacy.go index 7119663fa1..26aa6c5454 100644 --- a/cmd/skywire-cli/commands/visor/privacy.go +++ b/cmd/skywire-cli/commands/visor/privacy.go @@ -4,12 +4,10 @@ import ( "encoding/json" "fmt" - "github.com/spf13/cobra" - coincipher "github.com/skycoin/skycoin/src/cipher" + "github.com/spf13/cobra" clirpc "github.com/skycoin/skywire/cmd/skywire-cli/commands/rpc" - "github.com/skycoin/skywire/cmd/skywire-cli/internal" "github.com/skycoin/skywire/pkg/visor/privacyconfig" ) @@ -33,13 +31,13 @@ func init() { var privacyCmd = &cobra.Command{ Use: "priv", Short: "privacy settings", - Long: "configure privacy settings\n\ntest of the api endpoints GetPrivacy & SetPrivacy", + Long: "configure privacy settings", } var setPrivacyCmd = &cobra.Command{ Use: "set", Short: "set privacy.json via rpc", - Long: "configure privacy settings\n\ntest of the api endpoint SetPrivacy", + Long: "configure privacy settings", Run: func(cmd *cobra.Command, args []string) { client := clirpc.Client(cmd.Flags()) @@ -66,7 +64,7 @@ var setPrivacyCmd = &cobra.Command{ var getPrivacyCmd = &cobra.Command{ Use: "get", Short: "read privacy setting from file", - Long: "configure privacy settings\n\ntest of the api endpoints GetPrivacy", + Long: "configure privacy settings", Run: func(cmd *cobra.Command, args []string) { pConfig, err := clirpc.Client(cmd.Flags()).GetPrivacy() if err != nil { diff --git a/cmd/skywire-cli/commands/visor/root.go b/cmd/skywire-cli/commands/visor/root.go index 8194655262..db691d7d63 100644 --- a/cmd/skywire-cli/commands/visor/root.go +++ b/cmd/skywire-cli/commands/visor/root.go @@ -4,9 +4,15 @@ import ( "github.com/spf13/cobra" "github.com/skycoin/skywire-utilities/pkg/logging" + clirpc "github.com/skycoin/skywire/cmd/skywire-cli/commands/rpc" ) var logger = logging.MustGetLogger("skywire-cli") +var removeAll bool + +func init() { + RootCmd.PersistentFlags().StringVar(&clirpc.Addr, "rpc", "localhost:3435", "RPC server address") +} // RootCmd contains commands that interact with the skywire-visor var RootCmd = &cobra.Command{ diff --git a/cmd/skywire-cli/commands/visor/route.go b/cmd/skywire-cli/commands/visor/route.go index 2f62586646..7abe47c122 100644 --- a/cmd/skywire-cli/commands/visor/route.go +++ b/cmd/skywire-cli/commands/visor/route.go @@ -12,6 +12,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" + "github.com/skycoin/skywire-utilities/pkg/cipher" clirpc "github.com/skycoin/skywire/cmd/skywire-cli/commands/rpc" "github.com/skycoin/skywire/cmd/skywire-cli/internal" "github.com/skycoin/skywire/pkg/router" @@ -21,20 +22,11 @@ import ( var routeCmd = &cobra.Command{ Use: "route", Short: "View and set rules", -} - -var addRuleCmd = &cobra.Command{ - Use: "add-rule", - Short: "Add routing rule", + Long: "\n View and set routing rules", } func init() { RootCmd.AddCommand(routeCmd) - addRuleCmd.AddCommand( - addAppRuleCmd, - addFwdRuleCmd, - addIntFwdRuleCmd, - ) routeCmd.AddCommand( lsRulesCmd, ruleCmd, @@ -46,6 +38,7 @@ func init() { var lsRulesCmd = &cobra.Command{ Use: "ls-rules", Short: "List routing rules", + Long: "\n List routing rules", Run: func(cmd *cobra.Command, _ []string) { rules, err := clirpc.Client(cmd.Flags()).RoutingRules() internal.Catch(cmd.Flags(), err) @@ -57,7 +50,8 @@ var lsRulesCmd = &cobra.Command{ var ruleCmd = &cobra.Command{ Use: "rule ", Short: "Return routing rule by route ID key", - Args: cobra.MinimumNArgs(1), + Long: "\n Return routing rule by route ID key", + Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { id, err := strconv.ParseUint(args[0], 10, 32) internal.Catch(cmd.Flags(), err) @@ -69,47 +63,141 @@ var ruleCmd = &cobra.Command{ }, } +func init() { + rmRuleCmd.Flags().BoolVarP(&removeAll, "all", "a", false, "remove all routing rules") +} + var rmRuleCmd = &cobra.Command{ Use: "rm-rule ", Short: "Remove routing rule", - Args: cobra.MinimumNArgs(1), + Long: "\n Remove routing rule", + //Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { + //TODO + //if removeAll { + //rules, err := clirpc.Client(cmd.Flags()).RoutingRules() + //internal.Catch(cmd.Flags(), err) + //internal.Catch(cmd.Flags(), clirpc.Client(cmd.Flags()).RemoveRoutingRule(routing.RouteID(rules...))) + //} else { id, err := strconv.ParseUint(args[0], 10, 32) internal.Catch(cmd.Flags(), err) internal.Catch(cmd.Flags(), clirpc.Client(cmd.Flags()).RemoveRoutingRule(routing.RouteID(id))) + //} internal.PrintOutput(cmd.Flags(), "OK", "OK\n") }, } +var addRuleCmd = &cobra.Command{ + Use: "add-rule ( app | fwd | intfwd )", + Short: "Add routing rule", + Long: "\n Add routing rule", +} + var keepAlive time.Duration +var ( + nrID string + ntpID string + rID string + lPK string + lPt string + rPK string + rPt string +) + +//skywire-cli visor route add-rule app + func init() { - addRuleCmd.PersistentFlags().DurationVar(&keepAlive, "keep-alive", router.DefaultRouteKeepAlive, "duration after which routing rule will expire if no activity is present") + addRuleCmd.PersistentFlags().DurationVar(&keepAlive, "keep-alive", router.DefaultRouteKeepAlive, "timeout for rule expiration") + addRuleCmd.AddCommand( + addAppRuleCmd, + ) + addAppRuleCmd.Flags().SortFlags = false + addAppRuleCmd.Flags().StringVarP(&rID, "rid", "i", "", "route id") + addAppRuleCmd.Flags().StringVarP(&lPK, "lpk", "l", "", "local public key") + addAppRuleCmd.Flags().StringVarP(&lPt, "lpt", "m", "", "local port") + addAppRuleCmd.Flags().StringVarP(&rPK, "rpk", "p", "", "remote pk") + addAppRuleCmd.Flags().StringVarP(&rPt, "rpt", "q", "", "remote port") } var addAppRuleCmd = &cobra.Command{ - Use: "app ", + Use: "app \\\n \\\n \\\n \\\n \\\n \\\n || ", Short: "Add app/consume routing rule", + Long: "\n Add app/consume routing rule", Args: func(_ *cobra.Command, args []string) error { - if len(args) > 0 { - if len(args[0:]) == 5 { - return nil + if rID == "" && lPK == "" && lPt == "" && rPK == "" && rPt == "" { + if len(args) > 0 { + if len(args[0:]) == 5 { + return nil + } + return errors.New("expected 5 args after 'app'") } return errors.New("expected 5 args after 'app'") } - return errors.New("expected 5 args after 'app'") + return nil }, Run: func(cmd *cobra.Command, args []string) { - var rule routing.Rule var ( - routeID = routing.RouteID(parseUint(cmd.Flags(), "route-id", args[0], 32)) - localPK = internal.ParsePK(cmd.Flags(), "local-pk", args[1]) - localPort = routing.Port(parseUint(cmd.Flags(), "local-port", args[2], 16)) - remotePK = internal.ParsePK(cmd.Flags(), "remote-pk", args[3]) - remotePort = routing.Port(parseUint(cmd.Flags(), "remote-port", args[4], 16)) + rule routing.Rule + routeID routing.RouteID + localPK cipher.PubKey + localPort routing.Port + remotePK cipher.PubKey + remotePort routing.Port ) - rule = routing.ConsumeRule(keepAlive, routeID, localPK, remotePK, localPort, remotePort) + //use args if flags are empty strings + if rID == "" && lPK == "" && lPt == "" && rPK == "" && rPt == "" { + routeID = routing.RouteID(parseUint(cmd.Flags(), "route-id", args[0], 32)) + localPK = internal.ParsePK(cmd.Flags(), "local-pk", args[1]) + localPort = routing.Port(parseUint(cmd.Flags(), "local-port", args[2], 16)) + remotePK = internal.ParsePK(cmd.Flags(), "remote-pk", args[3]) + remotePort = routing.Port(parseUint(cmd.Flags(), "remote-port", args[4], 16)) + } else { + //the presence of every flag is enforced on an individual basis + if rID != "" { + i, err := strconv.ParseUint(rID, 10, 32) + if err != nil { + internal.PrintFatalError(cmd.Flags(), fmt.Errorf("failed to parse <%s>: %v", rID, err)) + } + routeID = routing.RouteID(i) + } else { + internal.PrintFatalError(cmd.Flags(), fmt.Errorf("required flag not specified")) + } + + if lPK != "" { + internal.Catch(cmd.Flags(), localPK.Set(lPK)) + } else { + internal.PrintFatalError(cmd.Flags(), fmt.Errorf("required flag not specified")) + } + if lPt != "" { + i, err := strconv.ParseUint(lPt, 10, 16) + if err != nil { + internal.PrintFatalError(cmd.Flags(), fmt.Errorf("failed to parse <%s>: %v", lPt, err)) + } + localPort = routing.Port(i) + } else { + internal.PrintFatalError(cmd.Flags(), fmt.Errorf("required flag not specified")) + } + + if rPK != "" { + internal.Catch(cmd.Flags(), remotePK.Set(rPK)) + } else { + internal.PrintFatalError(cmd.Flags(), fmt.Errorf("required flag not specified")) + } + + if rPt != "" { + i, err := strconv.ParseUint(rPt, 10, 16) + if err != nil { + internal.PrintFatalError(cmd.Flags(), fmt.Errorf("failed to parse <%s>: %v", rPt, err)) + } + localPort = routing.Port(i) + } else { + internal.PrintFatalError(cmd.Flags(), fmt.Errorf("required flag not specified")) + } + } + + rule = routing.ConsumeRule(keepAlive, routeID, localPK, remotePK, localPort, remotePort) var rIDKey routing.RouteID if rule != nil { rIDKey = rule.KeyRouteID() @@ -127,9 +215,26 @@ var addAppRuleCmd = &cobra.Command{ }, } +//skywire-cli visor route add-rule fwd + +func init() { + addRuleCmd.AddCommand( + addFwdRuleCmd, + ) + addFwdRuleCmd.Flags().SortFlags = false + addFwdRuleCmd.Flags().StringVarP(&rID, "rid", "i", "", "route id") + addFwdRuleCmd.Flags().StringVarP(&nrID, "nrid", "j", "", "next route id") + addFwdRuleCmd.Flags().StringVarP(&ntpID, "ntpid", "k", "", "next transport id") + addFwdRuleCmd.Flags().StringVarP(&lPK, "lpk", "l", "", "local public key") + addFwdRuleCmd.Flags().StringVarP(&lPt, "lpt", "m", "", "local port") + addFwdRuleCmd.Flags().StringVarP(&rPK, "rpk", "p", "", "remote pk") + addFwdRuleCmd.Flags().StringVarP(&rPt, "rpt", "q", "", "remote port") +} + var addFwdRuleCmd = &cobra.Command{ - Use: "fwd ", + Use: "fwd \\\n \\\n \\\n \\\n \\\n \\\n \\\n \\\n || ", Short: "Add forward routing rule", + Long: "\n Add forward routing rule", Args: func(_ *cobra.Command, args []string) error { if len(args) > 0 { if len(args[1:]) == 6 { @@ -168,9 +273,22 @@ var addFwdRuleCmd = &cobra.Command{ }, } +//skywire-cli visor route add-rule intfwd + +func init() { + addRuleCmd.AddCommand( + addIntFwdRuleCmd, + ) + addIntFwdRuleCmd.Flags().SortFlags = false + addIntFwdRuleCmd.Flags().StringVarP(&rID, "rid", "i", "", "route id") + addIntFwdRuleCmd.Flags().StringVarP(&nrID, "nrid", "n", "", "next route id") + addIntFwdRuleCmd.Flags().StringVarP(&rPt, "tpid", "t", "", "next transport id") +} + var addIntFwdRuleCmd = &cobra.Command{ - Use: "intfwd ", + Use: "intfwd \\\n \\\n \\\n \\\n || ", Short: "Add intermediary forward routing rule", + Long: "\n Add intermediary forward routing rule", Args: func(_ *cobra.Command, args []string) error { if len(args) > 0 { if len(args[0:]) == 3 { diff --git a/cmd/skywire-cli/commands/visor/shutdown.go b/cmd/skywire-cli/commands/visor/shutdown.go index 8bb52aad85..88cb7d9d54 100644 --- a/cmd/skywire-cli/commands/visor/shutdown.go +++ b/cmd/skywire-cli/commands/visor/shutdown.go @@ -16,6 +16,7 @@ func init() { var shutdownCmd = &cobra.Command{ Use: "halt", Short: "Stop a running visor", + Long: "\n Stop a running visor", Run: func(cmd *cobra.Command, args []string) { clirpc.Client(cmd.Flags()).Shutdown() //nolint fmt.Println("Visor was shut down") diff --git a/cmd/skywire-cli/commands/visor/start.go b/cmd/skywire-cli/commands/visor/start.go index d9badd3843..0945b1a344 100644 --- a/cmd/skywire-cli/commands/visor/start.go +++ b/cmd/skywire-cli/commands/visor/start.go @@ -29,6 +29,7 @@ func init() { var startCmd = &cobra.Command{ Use: "start", Short: "Start a visor", + Long: "\n Start a visor", Run: func(cmd *cobra.Command, args []string) { var output string var err error diff --git a/cmd/skywire-cli/commands/visor/transports.go b/cmd/skywire-cli/commands/visor/transports.go index 6b27a044d3..e7413d3992 100644 --- a/cmd/skywire-cli/commands/visor/transports.go +++ b/cmd/skywire-cli/commands/visor/transports.go @@ -23,10 +23,8 @@ import ( var ( filterTypes []string - filterPubKeys cipher.PubKeys + filterPubKeys []string showLogs bool - tpID transportID - tpPK cipher.PubKey ) func init() { @@ -40,8 +38,6 @@ func init() { rmTpCmd, discTpCmd, ) - discTpCmd.Flags().Var(&tpID, "id", "if specified, obtains a single transport of given ID") - discTpCmd.Flags().Var(&tpPK, "pk", "if specified, obtains transports associated with given public key") } // RootCmd contains commands that interact with the skywire-visor @@ -59,7 +55,10 @@ var tpCmd = &cobra.Command{ } var lsTypesCmd = &cobra.Command{ - Use: "type", Short: "Transport types used by the local visor", + Use: "type", + Short: "Transport types used by the local visor", + Long: "\n Transport types used by the local visor", + DisableFlagsInUseLine: true, Run: func(cmd *cobra.Command, _ []string) { types, err := clirpc.Client(cmd.Flags()).TransportTypes() internal.Catch(cmd.Flags(), err) @@ -68,28 +67,38 @@ var lsTypesCmd = &cobra.Command{ } func init() { - lsTpCmd.Flags().StringSliceVarP(&filterTypes, "types", "t", filterTypes, "show transport(s) type(s) comma-separated\n") - lsTpCmd.Flags().VarP(&filterPubKeys, "pks", "p", "show transport(s) for public key(s) comma-separated") + lsTpCmd.Flags().StringSliceVarP(&filterTypes, "types", "t", filterTypes, "show transport(s) type(s) comma-separated") + lsTpCmd.Flags().StringSliceVarP(&filterPubKeys, "pks", "p", filterPubKeys, "show transport(s) for public key(s) comma-separated") lsTpCmd.Flags().BoolVarP(&showLogs, "logs", "l", true, "show transport logs") } var lsTpCmd = &cobra.Command{ Use: "ls", Short: "Available transports", + Long: "\n Available transports\n\n displays transports of the local visor", Run: func(cmd *cobra.Command, _ []string) { - transports, err := clirpc.Client(cmd.Flags()).Transports(filterTypes, filterPubKeys, showLogs) + var pks cipher.PubKeys + + internal.Catch(cmd.Flags(), pks.Set(strings.Join(filterPubKeys, ","))) + transports, err := clirpc.Client(cmd.Flags()).Transports(filterTypes, pks, showLogs) internal.Catch(cmd.Flags(), err) PrintTransports(cmd.Flags(), transports...) }, } +func init() { + idCmd.Flags().StringVarP(&tpID, "id", "i", "", "transport ID") +} + var idCmd = &cobra.Command{ - Use: "id ", + Use: "id (-i) ", Short: "Transport summary by id", - Args: cobra.MinimumNArgs(1), + Long: "\n Transport summary by id", + DisableFlagsInUseLine: true, Run: func(cmd *cobra.Command, args []string) { - tpID := internal.ParseUUID(cmd.Flags(), "transport-id", args[0]) - tp, err := clirpc.Client(cmd.Flags()).Transport(tpID) + + tpid := internal.ParseUUID(cmd.Flags(), "transport-id", args[0]) + tp, err := clirpc.Client(cmd.Flags()).Transport(tpid) internal.Catch(cmd.Flags(), err) PrintTransports(cmd.Flags(), tp) }, @@ -98,27 +107,31 @@ var idCmd = &cobra.Command{ var ( transportType string timeout time.Duration + rpk string ) func init() { - const ( - typeFlagUsage = "type of transport to add; if unspecified, cli will attempt to establish a transport " + - "in the following order: skywire-tcp, stcpr, sudph, dmsg" - timeoutFlagUsage = "if specified, sets an operation timeout" - ) - - addTpCmd.Flags().StringVar(&transportType, "type", "", typeFlagUsage) - addTpCmd.Flags().DurationVarP(&timeout, "timeout", "t", 0, timeoutFlagUsage) + addTpCmd.Flags().StringVarP(&rpk, "rpk", "r", "", "remote public key.") + addTpCmd.Flags().StringVarP(&transportType, "type", "t", "", "type of transport to add.") + addTpCmd.Flags().DurationVarP(&timeout, "timeout", "o", 0, "if specified, sets an operation timeout") } var addTpCmd = &cobra.Command{ - Use: "add ", + Use: "add (-p) ", Short: "Add a transport", - Args: cobra.MinimumNArgs(1), + Long: "\n Add a transport\n \n If the transport type is unspecified,\n the visor will attempt to establish a transport\n in the following order: skywire-tcp, stcpr, sudph, dmsg", + Args: cobra.MinimumNArgs(1), + DisableFlagsInUseLine: true, Run: func(cmd *cobra.Command, args []string) { isJSON, _ := cmd.Flags().GetBool(internal.JSONString) //nolint:errcheck - pk := internal.ParsePK(cmd.Flags(), "remote-public-key", args[0]) + var pk cipher.PubKey + + if rpk == "" { + pk = internal.ParsePK(cmd.Flags(), "remote-public-key", args[0]) + } else { + internal.Catch(cmd.Flags(), pk.Set(rpk)) + } var tp *visor.TransportSummary var err error @@ -155,14 +168,32 @@ var addTpCmd = &cobra.Command{ }, } +func init() { + rmTpCmd.Flags().BoolVarP(&removeAll, "all", "a", false, "remove all transports") + rmTpCmd.Flags().StringVarP(&tpID, "id", "i", "", "remove transport of given ID") +} + var rmTpCmd = &cobra.Command{ - Use: "rm ", + Use: "rm ( -a || -i ) ", Short: "Remove transport(s) by id", - Args: cobra.MinimumNArgs(1), + Long: "\n Remove transport(s) by id", + DisableFlagsInUseLine: true, Run: func(cmd *cobra.Command, args []string) { - tID := internal.ParseUUID(cmd.Flags(), "transport-id", args[0]) + //TODO + //if removeAll { + // var pks cipher.PubKeys + // internal.Catch(cmd.Flags(), pks.Set(strings.Join(filterPubKeys, ","))) + // tID, err := clirpc.Client(cmd.Flags()).Transports(filterTypes, pks, showLogs) + // internal.Catch(cmd.Flags(), err) + // internal.Catch(cmd.Flags(), clirpc.Client(cmd.Flags()).RemoveTransport(tID)) + //} else { + if args[0] != "" { + tpID = args[0] + } + tID := internal.ParseUUID(cmd.Flags(), "transport-id", tpID) internal.Catch(cmd.Flags(), clirpc.Client(cmd.Flags()).RemoveTransport(tID)) internal.PrintOutput(cmd.Flags(), "OK", "OK\n") + //} }, } @@ -213,30 +244,41 @@ func sortTransports(tps ...*visor.TransportSummary) { }) } +var ( + tpID string + tpPK string +) + +func init() { + discTpCmd.Flags().StringVarP(&tpID, "id", "i", "", "obtain transport of given ID") + discTpCmd.Flags().StringVarP(&tpPK, "pk", "p", "", "obtain transports by public key") +} + var discTpCmd = &cobra.Command{ - Use: "disc (--id= | --pk=)", - Short: "Discover transport(s) by ID or public key", + Use: "disc (--id= || --pk=)", + Short: "Discover remote transport(s)", + Long: "\n Discover remote transport(s) by ID or public key", + DisableFlagsInUseLine: true, Args: func(_ *cobra.Command, _ []string) error { - var ( - nilID = uuid.UUID(tpID) == (uuid.UUID{}) - nilPK = tpPK.Null() - ) - if nilID && nilPK { - return errors.New("must specify --id flag or --pk flag") + if tpID == "" && tpPK == "" { + return errors.New("must specify either transport id or public key") } - if !nilID && !nilPK { - return errors.New("cannot specify --id and --pk flag") + if tpID != "" && tpPK != "" { + return errors.New("cannot specify both transport id and public key") } return nil }, Run: func(cmd *cobra.Command, _ []string) { - - if rc := clirpc.Client(cmd.Flags()); tpPK.Null() { - entry, err := rc.DiscoverTransportByID(uuid.UUID(tpID)) + var tppk cipher.PubKey + var tpid transportID + internal.Catch(cmd.Flags(), tpid.Set(tpID)) + internal.Catch(cmd.Flags(), tppk.Set(tpPK)) + if rc := clirpc.Client(cmd.Flags()); tppk.Null() { + entry, err := rc.DiscoverTransportByID(uuid.UUID(tpid)) internal.Catch(cmd.Flags(), err) PrintTransportEntries(cmd.Flags(), entry) } else { - entries, err := rc.DiscoverTransportsByPK(tpPK) + entries, err := rc.DiscoverTransportsByPK(tppk) internal.Catch(cmd.Flags(), err) PrintTransportEntries(cmd.Flags(), entries...) } diff --git a/cmd/skywire-cli/commands/vpn/vvpn.go b/cmd/skywire-cli/commands/vpn/vvpn.go index bc0db1213f..695302dc3d 100644 --- a/cmd/skywire-cli/commands/vpn/vvpn.go +++ b/cmd/skywire-cli/commands/vpn/vvpn.go @@ -19,6 +19,7 @@ import ( ) func init() { + RootCmd.PersistentFlags().StringVar(&clirpc.Addr, "rpc", "localhost:3435", "RPC server address") RootCmd.AddCommand( vpnListCmd, vpnUICmd, diff --git a/cmd/skywire-visor/commands/root.go b/cmd/skywire-visor/commands/root.go index 42f2a74831..e966ece9ad 100644 --- a/cmd/skywire-visor/commands/root.go +++ b/cmd/skywire-visor/commands/root.go @@ -49,6 +49,7 @@ var ( logger = logging.MustGetLogger("skywire-visor") tag string syslogAddr string + logLvl string pprofMode string pprofAddr string confPath string @@ -86,28 +87,11 @@ func init() { } rootCmd.Flags().SortFlags = false - + //the default is not set to fix the aesthetic of the help command rootCmd.Flags().StringVarP(&confPath, "config", "c", "", "config file to use (default): "+skyenv.ConfigName) if ((skyenv.OS == "linux") && !root) || ((skyenv.OS == "mac") && !root) || (skyenv.OS == "win") { rootCmd.Flags().BoolVarP(&launchBrowser, "browser", "b", false, "open hypervisor ui in default web browser") } - rootCmd.Flags().BoolVarP(&hypervisorUI, "hvui", "i", false, "run as hypervisor") - rootCmd.Flags().BoolVarP(&noHypervisorUI, "nohvui", "x", false, "disable hypervisor") - hiddenflags = append(hiddenflags, "nohvui") - rootCmd.Flags().StringVarP(&remoteHypervisorPKs, "hv", "j", "", "add remote hypervisor PKs at runtime") - hiddenflags = append(hiddenflags, "hv") - rootCmd.Flags().BoolVarP(&disableHypervisorPKs, "xhv", "k", false, "disable remote hypervisors set in config file") - hiddenflags = append(hiddenflags, "xhv") - if os.Getenv("SKYBIAN") == "true" { - rootCmd.Flags().StringVarP(&autoPeerIP, "hvip", "l", trimStringFromDot(localIPs[0].String())+".2:7998", "set hypervisor by ip") - hiddenflags = append(hiddenflags, "hvip") - isDefaultAutopeer := false - if os.Getenv("AUTOPEER") == "1" { - isDefaultAutopeer = true - } - rootCmd.Flags().BoolVarP(&isAutoPeer, "autopeer", "m", isDefaultAutopeer, "enable autopeering") - hiddenflags = append(hiddenflags, "autopeer") - } rootCmd.Flags().BoolVarP(&stdin, "stdin", "n", false, "read config from stdin") hiddenflags = append(hiddenflags, "stdin") if root { @@ -121,7 +105,26 @@ func init() { rootCmd.Flags().BoolVarP(&usr, "user", "u", false, "use config at: $HOME/"+skyenv.ConfigName) } } - rootCmd.Flags().StringVarP(&pprofMode, "pprofmode", "q", "", "pprof mode: cpu, mem, mutex, block, trace, http") + rootCmd.Flags().BoolVarP(&hypervisorUI, "hvui", "i", false, "run as hypervisor \u001b[0m*") + rootCmd.Flags().BoolVarP(&noHypervisorUI, "nohvui", "x", false, "disable hypervisor \u001b[0m*") + hiddenflags = append(hiddenflags, "nohvui") + rootCmd.Flags().StringVarP(&remoteHypervisorPKs, "hv", "j", "", "add remote hypervisor \u001b[0m*") + hiddenflags = append(hiddenflags, "hv") + rootCmd.Flags().BoolVarP(&disableHypervisorPKs, "xhv", "k", false, "disable remote hypervisors \u001b[0m*") + hiddenflags = append(hiddenflags, "xhv") + if os.Getenv("SKYBIAN") == "true" { + rootCmd.Flags().StringVarP(&autoPeerIP, "hvip", "l", trimStringFromDot(localIPs[0].String())+".2:7998", "set hypervisor by ip") + hiddenflags = append(hiddenflags, "hvip") + isDefaultAutopeer := false + if os.Getenv("AUTOPEER") == "1" { + isDefaultAutopeer = true + } + rootCmd.Flags().BoolVarP(&isAutoPeer, "autopeer", "m", isDefaultAutopeer, "enable autopeering") + hiddenflags = append(hiddenflags, "autopeer") + } + rootCmd.Flags().StringVarP(&logLvl, "loglvl", "s", "", "[ debug | warn | error | fatal | panic | trace ] \u001b[0m*") + hiddenflags = append(hiddenflags, "loglvl") + rootCmd.Flags().StringVarP(&pprofMode, "pprofmode", "q", "", "[ cpu | mem | mutex | block | trace | http ]") hiddenflags = append(hiddenflags, "pprofmode") rootCmd.Flags().StringVarP(&pprofAddr, "pprofaddr", "r", "localhost:6060", "pprof http port") hiddenflags = append(hiddenflags, "pprofaddr") @@ -159,8 +162,10 @@ var rootCmd = &cobra.Command{ f := cmd.Flags().Lookup(j) //nolint f.Hidden = false } - cmd.Flags().MarkHidden("all") //nolint - cmd.Help() //nolint + cmd.Flags().MarkHidden("all") //nolint + cmd.Flags().MarkHidden("help") //nolint + cmd.Help() //nolint + fmt.Println(" * \u001b[94moverrides config file\u001b[0m") os.Exit(0) } // -z --completion @@ -334,6 +339,16 @@ func runVisor(conf *visorconfig.V1) { } } } + if logLvl != "" { + //validate & set log level + _, err := logging.LevelFromString(logLvl) + if err != nil { + log.WithError(err).Error("Invalid log level specified: ", logLvl) + } else { + conf.LogLevel = logLvl + log.Info("setting log level to: ", logLvl) + } + } ctx, cancel := cmdutil.SignalContext(context.Background(), log) vis, ok := visor.NewVisor(ctx, conf, restartCtx, isAutoPeer, autoPeerIP) diff --git a/pkg/visor/privacyconfig/privacy.go b/pkg/visor/privacyconfig/privacy.go index d91abeddc4..3d6266134b 100644 --- a/pkg/visor/privacyconfig/privacy.go +++ b/pkg/visor/privacyconfig/privacy.go @@ -1,3 +1,4 @@ +// Package privacyconfig pkg/visor/privacyconfig/privacy.go package privacyconfig import (