diff --git a/cmd/skywire-cli/commands/log/root.go b/cmd/skywire-cli/commands/log/root.go index e1be164c38..b7dbc78570 100644 --- a/cmd/skywire-cli/commands/log/root.go +++ b/cmd/skywire-cli/commands/log/root.go @@ -79,6 +79,10 @@ var logCmd = &cobra.Command{ Long: "Fetch health, survey, and transport logging from visors which are online in the uptime tracker\nhttp://ut.skywire.skycoin.com/uptimes?v=v2\nhttp://ut.skywire.skycoin.com/uptimes?v=v2&visors=;;", Run: func(cmd *cobra.Command, args []string) { log := logging.MustGetLogger("log-collecting") + fver, err := version.NewVersion("v1.3.17") + if err != nil { + log.Fatal("can't parse version for filtering fetches") + } if logOnly && surveyOnly { log.Fatal("use of mutually exclusive flags --log and --survey") } @@ -202,7 +206,11 @@ var logCmd = &cobra.Command{ } } if !logOnly { - download(ctx, log, httpC, "node-info.json", "node-info.json", key, maxFileSize) //nolint + if visorVersion.LessThan(fver) { + download(ctx, log, httpC, "node-info.json", "node-info.json", key, maxFileSize) //nolint + } else { + download(ctx, log, httpC, "node-info", "node-info.json", key, maxFileSize) //nolint + } } if !surveyOnly { for i := 0; i <= duration; i++ { diff --git a/cmd/skywire-cli/commands/reward/calc.go b/cmd/skywire-cli/commands/rewards/calc.go similarity index 88% rename from cmd/skywire-cli/commands/reward/calc.go rename to cmd/skywire-cli/commands/rewards/calc.go index 7f85655bb8..d1f5c93821 100644 --- a/cmd/skywire-cli/commands/reward/calc.go +++ b/cmd/skywire-cli/commands/rewards/calc.go @@ -1,5 +1,5 @@ -// Package clireward cmd/skywire-cli/commands/reward/root.go -package clireward +// Package clirewards cmd/skywire-cli/commands/rewards/calc.go +package clirewards import ( "fmt" @@ -54,23 +54,22 @@ type rewardData struct { } func init() { - RootCmd.AddCommand(rewardCalcCmd) - rewardCalcCmd.Flags().SortFlags = false - rewardCalcCmd.Flags().StringVarP(&wdate, "date", "d", wdate, "date for which to calculate reward") - rewardCalcCmd.Flags().StringVarP(&pubkey, "pk", "k", pubkey, "check reward for pubkey") - rewardCalcCmd.Flags().StringVarP(&disallowArchitectures, "noarch", "n", "amd64", "disallowed architectures, comma separated") - rewardCalcCmd.Flags().IntVarP(&yearlyTotal, "year", "y", yearlyTotalRewards, "yearly total rewards") - rewardCalcCmd.Flags().StringVarP(&utfile, "utfile", "u", "ut.txt", "uptime tracker data file") - rewardCalcCmd.Flags().StringVarP(&surveyPath, "path", "p", "log_collecting", "path to the surveys") - rewardCalcCmd.Flags().BoolVarP(&h0, "h0", "0", false, "hide statistical data") - rewardCalcCmd.Flags().BoolVarP(&h1, "h1", "1", false, "hide survey csv data") - rewardCalcCmd.Flags().BoolVarP(&h2, "h2", "2", false, "hide reward csv data") - rewardCalcCmd.Flags().BoolVarP(&grr, "err", "e", false, "account for non rewarded keys") - + RootCmd.Flags().SortFlags = false + RootCmd.Flags().StringVarP(&wdate, "date", "d", wdate, "date for which to calculate reward") + RootCmd.Flags().StringVarP(&pubkey, "pk", "k", pubkey, "check reward for pubkey") + RootCmd.Flags().StringVarP(&disallowArchitectures, "noarch", "n", "amd64", "disallowed architectures, comma separated") + RootCmd.Flags().IntVarP(&yearlyTotal, "year", "y", yearlyTotalRewards, "yearly total rewards") + RootCmd.Flags().StringVarP(&utfile, "utfile", "u", "ut.txt", "uptime tracker data file") + RootCmd.Flags().StringVarP(&surveyPath, "path", "p", "log_collecting", "path to the surveys") + RootCmd.Flags().BoolVarP(&h0, "h0", "0", false, "hide statistical data") + RootCmd.Flags().BoolVarP(&h1, "h1", "1", false, "hide survey csv data") + RootCmd.Flags().BoolVarP(&h2, "h2", "2", false, "hide reward csv data") + RootCmd.Flags().BoolVarP(&grr, "err", "e", false, "account for non rewarded keys") } -var rewardCalcCmd = &cobra.Command{ - Use: "calc", +// RootCmd is the root command for skywire-cli rewards +var RootCmd = &cobra.Command{ + Use: "rewards", Short: "calculate rewards from uptime data & collected surveys", Long: ` Collect surveys: skywire-cli log diff --git a/cmd/skywire-cli/commands/root.go b/cmd/skywire-cli/commands/root.go index 09e18ffa0b..52c0e1f9f8 100644 --- a/cmd/skywire-cli/commands/root.go +++ b/cmd/skywire-cli/commands/root.go @@ -21,6 +21,7 @@ import ( climdisc "github.com/skycoin/skywire/cmd/skywire-cli/commands/mdisc" cliskysocksc "github.com/skycoin/skywire/cmd/skywire-cli/commands/proxy" clireward "github.com/skycoin/skywire/cmd/skywire-cli/commands/reward" + clirewards "github.com/skycoin/skywire/cmd/skywire-cli/commands/rewards" clirtfind "github.com/skycoin/skywire/cmd/skywire-cli/commands/rtfind" cliservices "github.com/skycoin/skywire/cmd/skywire-cli/commands/services" cliskyfwd "github.com/skycoin/skywire/cmd/skywire-cli/commands/skyfwd" @@ -189,6 +190,7 @@ func init() { cliskyfwd.RootCmd, cliskyrev.RootCmd, clireward.RootCmd, + clirewards.RootCmd, clisurvey.RootCmd, clirtfind.RootCmd, climdisc.RootCmd, diff --git a/go.mod b/go.mod index d0874743ce..2681a9c4b4 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/orandin/lumberjackrus v1.0.1 github.com/pterm/pterm v0.12.66 github.com/sirupsen/logrus v1.9.3 - github.com/skycoin/dmsg v1.3.17 + github.com/skycoin/dmsg v1.3.18-0.20240210174503-ecde4c538de6 github.com/skycoin/skycoin v0.27.1 github.com/skycoin/skycoin-service-discovery v0.0.0-20231221001759-d1af6ec27db1 github.com/skycoin/skywire-services v0.0.0-20240207001624-ebee7346e526 diff --git a/go.sum b/go.sum index b57fbb68c1..8abf44008a 100644 --- a/go.sum +++ b/go.sum @@ -434,16 +434,14 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/skycoin/dmsg v1.3.17 h1:CUq8u4ABDKFkE4ppscJ/R09hMtfPUE72Rleq078vQ28= -github.com/skycoin/dmsg v1.3.17/go.mod h1:INEDx+ECwCGQWw/Kd0QcLmSWMhbeRRcfkxj+xATQGFg= +github.com/skycoin/dmsg v1.3.18-0.20240210174503-ecde4c538de6 h1:+FJ4PdoWc6W43qph/6TF1TIXWwc51uPCpRrbJ0Dkp/E= +github.com/skycoin/dmsg v1.3.18-0.20240210174503-ecde4c538de6/go.mod h1:INEDx+ECwCGQWw/Kd0QcLmSWMhbeRRcfkxj+xATQGFg= github.com/skycoin/noise v0.0.0-20180327030543-2492fe189ae6 h1:1Nc5EBY6pjfw1kwW0duwyG+7WliWz5u9kgk1h5MnLuA= github.com/skycoin/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:UXghlricA7J3aRD/k7p/zBObQfmBawwCxIVPVjz2Q3o= github.com/skycoin/skycoin v0.27.1 h1:HatxsRwVSPaV4qxH6290xPBmkH/HgiuAoY2qC+e8C9I= github.com/skycoin/skycoin v0.27.1/go.mod h1:78nHjQzd8KG0jJJVL/j0xMmrihXi70ti63fh8vXScJw= github.com/skycoin/skycoin-service-discovery v0.0.0-20231221001759-d1af6ec27db1 h1:CQpzVCMiAZfL3NsByipzzPDIzBRJA00AURU/9Pctq1E= github.com/skycoin/skycoin-service-discovery v0.0.0-20231221001759-d1af6ec27db1/go.mod h1:6VwZDwW4aO6fucuZKiJQ4PnnVYi5CfN/eHcK8F0C05M= -github.com/skycoin/skywire-services v0.0.0-20231221001820-3212895ddf12 h1:fic0WKltARs0JnbNFcKesijNgcPOeJh7CsFs/KLZoJw= -github.com/skycoin/skywire-services v0.0.0-20231221001820-3212895ddf12/go.mod h1:HYqBsmgat3wTk1zwGLNj3q5N3iCpJOwYOuLexqKH02k= github.com/skycoin/skywire-services v0.0.0-20240207001624-ebee7346e526 h1:9Fs12yw4gpNwb/D7FtRZj1BfOMM3GkWt7NYM16K0+tM= github.com/skycoin/skywire-services v0.0.0-20240207001624-ebee7346e526/go.mod h1:KfJQ6p13LpG+gBwzASh5ehZSi059aX44E/E4wQM2780= github.com/skycoin/skywire-utilities v1.3.17 h1:89aPdViJxhMpjEJbByQ02W8anX6Oxt68OeSxAENBlFI= @@ -547,7 +545,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -581,7 +578,6 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191003171128-d98b1b443823/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= @@ -620,7 +616,6 @@ golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200428200454-593003d681fa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -694,8 +689,6 @@ golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeu golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI= golang.zx2c4.com/wireguard v0.0.0-20230223181233-21636207a675 h1:/J/RVnr7ng4fWPRH3xa4WtBJ1Jp+Auu4YNLmGiPv5QU= golang.zx2c4.com/wireguard v0.0.0-20230223181233-21636207a675/go.mod h1:whfbyDBt09xhCYQWtO2+3UVjlaq6/9hDZrjg2ZE6SyA= -golang.zx2c4.com/wireguard v0.0.20200320 h1:1vE6zVeO7fix9cJX1Z9ZQ+ikPIIx7vIyU0o0tLDD88g= -golang.zx2c4.com/wireguard v0.0.20200320/go.mod h1:lDian4Sw4poJ04SgHh35nzMVwGSYlPumkdnHcucAQoY= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= diff --git a/vendor/github.com/skycoin/dmsg/cmd/dmsg-discovery/commands/root.go b/vendor/github.com/skycoin/dmsg/cmd/dmsg-discovery/commands/dmsg-discovery.go similarity index 85% rename from vendor/github.com/skycoin/dmsg/cmd/dmsg-discovery/commands/root.go rename to vendor/github.com/skycoin/dmsg/cmd/dmsg-discovery/commands/dmsg-discovery.go index 2f1a84009d..c0cb7e0df3 100644 --- a/vendor/github.com/skycoin/dmsg/cmd/dmsg-discovery/commands/root.go +++ b/vendor/github.com/skycoin/dmsg/cmd/dmsg-discovery/commands/dmsg-discovery.go @@ -12,7 +12,6 @@ import ( "strings" "time" - cc "github.com/ivanpirog/coloredcobra" proxyproto "github.com/pires/go-proxyproto" "github.com/sirupsen/logrus" "github.com/skycoin/skywire-utilities/pkg/buildinfo" @@ -64,21 +63,18 @@ func init() { RootCmd.Flags().BoolVar(&testEnvironment, "test-environment", false, "distinguished between prod and test environment") RootCmd.Flags().Var(&sk, "sk", "dmsg secret key\n") RootCmd.Flags().Uint16Var(&dmsgPort, "dmsgPort", dmsg.DefaultDmsgHTTPPort, "dmsg port value\r") - var helpflag bool - RootCmd.SetUsageTemplate(help) - RootCmd.PersistentFlags().BoolVarP(&helpflag, "help", "h", false, "help for dmsg-discovery") - RootCmd.SetHelpCommand(&cobra.Command{Hidden: true}) - RootCmd.PersistentFlags().MarkHidden("help") //nolint + } // RootCmd contains commands for dmsg-discovery var RootCmd = &cobra.Command{ Use: "disc", - Short: "Dmsg Discovery Server for skywire", + Short: "DMSG Discovery Server", Long: ` ┌┬┐┌┬┐┌─┐┌─┐ ┌┬┐┬┌─┐┌─┐┌─┐┬ ┬┌─┐┬─┐┬ ┬ │││││└─┐│ ┬───│││└─┐│ │ │└┐┌┘├┤ ├┬┘└┬┘ - ─┴┘┴ ┴└─┘└─┘ ─┴┘┴└─┘└─┘└─┘ └┘ └─┘┴└─ ┴ `, + ─┴┘┴ ┴└─┘└─┘ ─┴┘┴└─┘└─┘└─┘ └┘ └─┘┴└─ ┴ + ` + "DMSG Discovery Server", SilenceErrors: true, SilenceUsage: true, DisableSuggestions: true, @@ -186,34 +182,11 @@ var RootCmd = &cobra.Command{ // Execute executes root CLI command. func Execute() { - cc.Init(&cc.Config{ - RootCmd: RootCmd, - Headings: cc.HiBlue + cc.Bold, //+ cc.Underline, - Commands: cc.HiBlue + cc.Bold, - CmdShortDescr: cc.HiBlue, - Example: cc.HiBlue + cc.Italic, - ExecName: cc.HiBlue + cc.Bold, - Flags: cc.HiBlue + cc.Bold, - //FlagsDataType: cc.HiBlue, - FlagsDescr: cc.HiBlue, - NoExtraNewlines: true, - NoBottomNewline: true, - }) if err := RootCmd.Execute(); err != nil { log.Fatal(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" - func prepareDB(ctx context.Context, log *logging.Logger) store.Storer { dbConf := &store.Config{ URL: redisURL, diff --git a/vendor/github.com/skycoin/dmsg/cmd/dmsg-server/commands/root.go b/vendor/github.com/skycoin/dmsg/cmd/dmsg-server/commands/root.go index 743663d634..6a1557acac 100644 --- a/vendor/github.com/skycoin/dmsg/cmd/dmsg-server/commands/root.go +++ b/vendor/github.com/skycoin/dmsg/cmd/dmsg-server/commands/root.go @@ -4,7 +4,6 @@ package commands import ( "log" - cc "github.com/ivanpirog/coloredcobra" "github.com/skycoin/skywire-utilities/pkg/buildinfo" "github.com/spf13/cobra" @@ -17,21 +16,18 @@ func init() { config.RootCmd, start.RootCmd, ) - RootCmd.SetUsageTemplate(help) - var helpflag bool - RootCmd.PersistentFlags().BoolVarP(&helpflag, "help", "h", false, "help for dmsg-server") - RootCmd.SetHelpCommand(&cobra.Command{Hidden: true}) - RootCmd.PersistentFlags().MarkHidden("help") //nolint + } // RootCmd contains the root dmsg-server command var RootCmd = &cobra.Command{ Use: "server", - Short: "Command Line Interface for DMSG-Server", + Short: "DMSG Server", Long: ` ┌┬┐┌┬┐┌─┐┌─┐ ┌─┐┌─┐┬─┐┬ ┬┌─┐┬─┐ ││││││└─┐│ ┬ ─ └─┐├┤ ├┬┘└┐┌┘├┤ ├┬┘ - ─┴┘┴ ┴└─┘└─┘ └─┘└─┘┴└─ └┘ └─┘┴└─`, + ─┴┘┴ ┴└─┘└─┘ └─┘└─┘┴└─ └┘ └─┘┴└─ + ` + "DMSG Server", SilenceErrors: true, SilenceUsage: true, DisableSuggestions: true, @@ -41,30 +37,7 @@ var RootCmd = &cobra.Command{ // Execute executes root CLI command. func Execute() { - cc.Init(&cc.Config{ - RootCmd: RootCmd, - Headings: cc.HiBlue + cc.Bold, //+ cc.Underline, - Commands: cc.HiBlue + cc.Bold, - CmdShortDescr: cc.HiBlue, - Example: cc.HiBlue + cc.Italic, - ExecName: cc.HiBlue + cc.Bold, - Flags: cc.HiBlue + cc.Bold, - //FlagsDataType: cc.HiBlue, - FlagsDescr: cc.HiBlue, - 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/vendor/github.com/skycoin/dmsg/cmd/dmsgcurl/commands/dmsgcurl.go b/vendor/github.com/skycoin/dmsg/cmd/dmsgcurl/commands/dmsgcurl.go index e9ddafff36..df454c5f87 100644 --- a/vendor/github.com/skycoin/dmsg/cmd/dmsgcurl/commands/dmsgcurl.go +++ b/vendor/github.com/skycoin/dmsg/cmd/dmsgcurl/commands/dmsgcurl.go @@ -16,7 +16,6 @@ import ( "sync/atomic" "time" - cc "github.com/ivanpirog/coloredcobra" "github.com/sirupsen/logrus" "github.com/skycoin/skywire-utilities/pkg/buildinfo" "github.com/skycoin/skywire-utilities/pkg/cipher" @@ -60,21 +59,17 @@ func init() { sk.Set(os.Getenv("DMSGCURL_SK")) //nolint } RootCmd.Flags().VarP(&sk, "sk", "s", "a random key is generated if unspecified\n\r") - var helpflag bool - RootCmd.SetUsageTemplate(help) - RootCmd.PersistentFlags().BoolVarP(&helpflag, "help", "h", false, "help for dmsgcurl") - RootCmd.SetHelpCommand(&cobra.Command{Hidden: true}) - RootCmd.PersistentFlags().MarkHidden("help") //nolint } // RootCmd containsa the root dmsgcurl command var RootCmd = &cobra.Command{ - Short: "dmsgcurl", + Short: "DMSG curl utility", Use: "dmsgcurl [OPTIONS] ... [URL]", Long: ` - ┌┬┐┌┬┐┌─┐┌─┐┌─┐┬ ┬┬─┐┬ - │││││└─┐│ ┬│ │ │├┬┘│ - ─┴┘┴ ┴└─┘└─┘└─┘└─┘┴└─┴─┘`, + ┌┬┐┌┬┐┌─┐┌─┐┌─┐┬ ┬┬─┐┬ + │││││└─┐│ ┬│ │ │├┬┘│ + ─┴┘┴ ┴└─┘└─┘└─┘└─┘┴└─┴─┘ + ` + "DMSG curl utility", SilenceErrors: true, SilenceUsage: true, DisableSuggestions: true, @@ -359,30 +354,7 @@ func (pw *ProgressWriter) Write(p []byte) (int, error) { // Execute executes root CLI command. func Execute() { - cc.Init(&cc.Config{ - RootCmd: RootCmd, - Headings: cc.HiBlue + cc.Bold, //+ cc.Underline, - Commands: cc.HiBlue + cc.Bold, - CmdShortDescr: cc.HiBlue, - Example: cc.HiBlue + cc.Italic, - ExecName: cc.HiBlue + cc.Bold, - Flags: cc.HiBlue + cc.Bold, - //FlagsDataType: cc.HiBlue, - FlagsDescr: cc.HiBlue, - 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/vendor/github.com/skycoin/dmsg/cmd/dmsghttp/commands/dmsghttp.go b/vendor/github.com/skycoin/dmsg/cmd/dmsghttp/commands/dmsghttp.go index 78cc5e9a01..d5ddbb1882 100644 --- a/vendor/github.com/skycoin/dmsg/cmd/dmsghttp/commands/dmsghttp.go +++ b/vendor/github.com/skycoin/dmsg/cmd/dmsghttp/commands/dmsghttp.go @@ -14,7 +14,6 @@ import ( "strings" "time" - cc "github.com/ivanpirog/coloredcobra" "github.com/skycoin/skywire-utilities/pkg/buildinfo" "github.com/skycoin/skywire-utilities/pkg/cipher" "github.com/skycoin/skywire-utilities/pkg/cmdutil" @@ -44,21 +43,18 @@ func init() { sk.Set(os.Getenv("DMSGHTTP_SK")) //nolint } RootCmd.Flags().VarP(&sk, "sk", "s", "a random key is generated if unspecified\n\r") - var helpflag bool - RootCmd.SetUsageTemplate(help) - RootCmd.PersistentFlags().BoolVarP(&helpflag, "help", "h", false, "help for dmsghttp") - RootCmd.SetHelpCommand(&cobra.Command{Hidden: true}) - RootCmd.PersistentFlags().MarkHidden("help") //nolint + } // RootCmd contains the root dmsghttp command var RootCmd = &cobra.Command{ Use: "http", - Short: "dmsghttp file server", + Short: "DMSG http file server", Long: ` ┌┬┐┌┬┐┌─┐┌─┐┬ ┬┌┬┐┌┬┐┌─┐ │││││└─┐│ ┬├─┤ │ │ ├─┘ - ─┴┘┴ ┴└─┘└─┘┴ ┴ ┴ ┴ ┴ `, + ─┴┘┴ ┴└─┘└─┘┴ ┴ ┴ ┴ ┴ + ` + "DMSG http file server", SilenceErrors: true, SilenceUsage: true, DisableSuggestions: true, @@ -190,30 +186,7 @@ func fileServerHandler(w http.ResponseWriter, r *http.Request) { // Execute executes root CLI command. func Execute() { - cc.Init(&cc.Config{ - RootCmd: RootCmd, - Headings: cc.HiBlue + cc.Bold, //+ cc.Underline, - Commands: cc.HiBlue + cc.Bold, - CmdShortDescr: cc.HiBlue, - Example: cc.HiBlue + cc.Italic, - ExecName: cc.HiBlue + cc.Bold, - Flags: cc.HiBlue + cc.Bold, - //FlagsDataType: cc.HiBlue, - FlagsDescr: cc.HiBlue, - 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/vendor/github.com/skycoin/dmsg/cmd/dmsgpty-cli/commands/root.go b/vendor/github.com/skycoin/dmsg/cmd/dmsgpty-cli/commands/root.go index e01800d360..785ceb3619 100644 --- a/vendor/github.com/skycoin/dmsg/cmd/dmsgpty-cli/commands/root.go +++ b/vendor/github.com/skycoin/dmsg/cmd/dmsgpty-cli/commands/root.go @@ -7,7 +7,6 @@ import ( "log" "os" - cc "github.com/ivanpirog/coloredcobra" "github.com/skycoin/skywire-utilities/pkg/buildinfo" "github.com/skycoin/skywire-utilities/pkg/cmdutil" "github.com/spf13/cobra" @@ -30,33 +29,72 @@ var ( ) func init() { - RootCmd.PersistentFlags().StringVar(&cli.Net, "clinet", cli.Net, "network to use for dialing to dmsgpty-host") - RootCmd.PersistentFlags().StringVar(&cli.Addr, "cliaddr", cli.Addr, "address to use for dialing to dmsgpty-host") - RootCmd.PersistentFlags().StringVarP(&confPath, "confpath", confPath, defaultConfPath, "config path") - cobra.OnInitialize(initConfig) + RootCmd.Flags().StringVarP(&cli.Net, "clinet", "n", cli.Net, "network to use for dialing to dmsgpty-host") + RootCmd.Flags().StringVarP(&cli.Addr, "cliaddr", "r", cli.Addr, "address to use for dialing to dmsgpty-host") + RootCmd.Flags().StringVarP(&confPath, "confpath", "p", defaultConfPath, "config path") RootCmd.Flags().Var(&remoteAddr, "addr", "remote dmsg address of format 'pk:port'\n If unspecified, the pty will start locally\n") RootCmd.Flags().StringVarP(&cmdName, "cmd", "c", cmdName, "name of command to run\n") RootCmd.Flags().StringSliceVarP(&cmdArgs, "args", "a", cmdArgs, "command arguments") - var helpflag bool - RootCmd.SetUsageTemplate(help) - RootCmd.PersistentFlags().BoolVarP(&helpflag, "help", "h", false, "help for dmsgpty-cli") - RootCmd.SetHelpCommand(&cobra.Command{Hidden: true}) - RootCmd.PersistentFlags().MarkHidden("help") //nolint } // RootCmd contains commands for dmsgpty-cli; which interacts with the dmsgpty-host instance (i.e. skywire-visor) var RootCmd = &cobra.Command{ Use: "cli", - Short: "Run commands over dmsg", + Short: "DMSG pseudoterminal command line interface", Long: ` ┌┬┐┌┬┐┌─┐┌─┐┌─┐┌┬┐┬ ┬ ┌─┐┬ ┬ │││││└─┐│ ┬├─┘ │ └┬┘───│ │ │ - ─┴┘┴ ┴└─┘└─┘┴ ┴ ┴ └─┘┴─┘┴`, + ─┴┘┴ ┴└─┘└─┘┴ ┴ ┴ └─┘┴─┘┴ + ` + "DMSG pseudoterminal command line interface", SilenceErrors: true, SilenceUsage: true, DisableSuggestions: true, DisableFlagsInUseLine: true, PreRun: func(*cobra.Command, []string) { + // source whitelist from config file + // by default : it will look for config + // + // case 1 : config file is new (does not contain a "wl" key) + // - create a "wl" key within the config file + // + // case 2 : config file is old (already contains "wl" key) + // - load config file into memory to manipulate whitelists + // - writes changes back to config file + println(confPath) + + if _, err := os.Stat(confPath); err != nil { + cli.Log.Fatalf("Config file %s not found.", confPath) + } + + // read file using ioutil + file, err := os.ReadFile(confPath) //nolint:gosec + if err != nil { + cli.Log.Fatalln("Unable to read ", confPath, err) + } + + // store config.json into conf to manipulate whitelists + err = json.Unmarshal(file, &conf) + if err != nil { + cli.Log.Errorln(err) + // ignoring this error + b, err := json.MarshalIndent(conf, "", " ") + if err != nil { + cli.Log.Fatalln("Unable to marshal conf") + } + + // write to config.json + err = os.WriteFile(confPath, b, 0600) + if err != nil { + cli.Log.Fatalln("Unable to write", confPath, err) + } + } + conf.CLIAddr = dmsgpty.ParseWindowsEnv(conf.CLIAddr) + if conf.CLIAddr != "" { + cli.Addr = conf.CLIAddr + } + if conf.CLINet != "" { + cli.Net = conf.CLINet + } if remoteAddr.Port == 0 { remoteAddr.Port = dmsgpty.DefaultPort } @@ -80,78 +118,7 @@ var RootCmd = &cobra.Command{ // Execute executes the root command. func Execute() { - cc.Init(&cc.Config{ - RootCmd: RootCmd, - Headings: cc.HiBlue + cc.Bold, //+ cc.Underline, - Commands: cc.HiBlue + cc.Bold, - CmdShortDescr: cc.HiBlue, - Example: cc.HiBlue + cc.Italic, - ExecName: cc.HiBlue + cc.Bold, - Flags: cc.HiBlue + cc.Bold, - //FlagsDataType: cc.HiBlue, - FlagsDescr: cc.HiBlue, - NoExtraNewlines: true, - NoBottomNewline: true, - }) if err := RootCmd.Execute(); err != nil { log.Fatal(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" - -// initConfig sources whitelist from config file -// by default : it will look for config -// -// case 1 : config file is new (does not contain a "wl" key) -// - create a "wl" key within the config file -// -// case 2 : config file is old (already contains "wl" key) -// - load config file into memory to manipulate whitelists -// - writes changes back to config file -func initConfig() { - - println(confPath) - - if _, err := os.Stat(confPath); err != nil { - cli.Log.Fatalf("Config file %s not found.", confPath) - } - - // read file using ioutil - file, err := os.ReadFile(confPath) //nolint:gosec - if err != nil { - cli.Log.Fatalln("Unable to read ", confPath, err) - } - - // store config.json into conf to manipulate whitelists - err = json.Unmarshal(file, &conf) - if err != nil { - cli.Log.Errorln(err) - // ignoring this error - b, err := json.MarshalIndent(conf, "", " ") - if err != nil { - cli.Log.Fatalln("Unable to marshal conf") - } - - // write to config.json - err = os.WriteFile(confPath, b, 0600) - if err != nil { - cli.Log.Fatalln("Unable to write", confPath, err) - } - } - conf.CLIAddr = dmsgpty.ParseWindowsEnv(conf.CLIAddr) - if conf.CLIAddr != "" { - cli.Addr = conf.CLIAddr - } - if conf.CLINet != "" { - cli.Net = conf.CLINet - } -} diff --git a/vendor/github.com/skycoin/dmsg/cmd/dmsgpty-host/commands/root.go b/vendor/github.com/skycoin/dmsg/cmd/dmsgpty-host/commands/root.go index d10ea218a4..043c791944 100644 --- a/vendor/github.com/skycoin/dmsg/cmd/dmsgpty-host/commands/root.go +++ b/vendor/github.com/skycoin/dmsg/cmd/dmsgpty-host/commands/root.go @@ -12,7 +12,6 @@ import ( "strings" "sync" - cc "github.com/ivanpirog/coloredcobra" jsoniter "github.com/json-iterator/go" "github.com/sirupsen/logrus" "github.com/skycoin/skywire-utilities/pkg/buildinfo" @@ -56,31 +55,28 @@ var ( func init() { // Prepare flags with env/config references. - RootCmd.PersistentFlags().Var(&wl, "wl", "whitelist of the dmsgpty-host") - RootCmd.PersistentFlags().StringVar(&dmsgDisc, "dmsgdisc", dmsgDisc, "dmsg discovery address") - RootCmd.PersistentFlags().IntVar(&dmsgSessions, "dmsgsessions", dmsgSessions, "minimum number of dmsg sessions to ensure") - RootCmd.PersistentFlags().Uint16Var(&dmsgPort, "dmsgport", dmsgPort, "dmsg port for listening for remote hosts") - RootCmd.PersistentFlags().StringVar(&cliNet, "clinet", cliNet, "network used for listening for cli connections") - RootCmd.PersistentFlags().StringVar(&cliAddr, "cliaddr", cliAddr, "address used for listening for cli connections") + RootCmd.Flags().Var(&wl, "wl", "whitelist of the dmsgpty-host") + RootCmd.Flags().StringVar(&dmsgDisc, "dmsgdisc", dmsgDisc, "dmsg discovery address") + RootCmd.Flags().IntVar(&dmsgSessions, "dmsgsessions", dmsgSessions, "minimum number of dmsg sessions to ensure") + RootCmd.Flags().Uint16Var(&dmsgPort, "dmsgport", dmsgPort, "dmsg port for listening for remote hosts") + RootCmd.Flags().StringVar(&cliNet, "clinet", cliNet, "network used for listening for cli connections") + RootCmd.Flags().StringVar(&cliAddr, "cliaddr", cliAddr, "address used for listening for cli connections") // Prepare flags without associated env/config references. - RootCmd.PersistentFlags().StringVar(&envPrefix, "envprefix", envPrefix, "env prefix") + RootCmd.Flags().StringVar(&envPrefix, "envprefix", envPrefix, "env prefix") RootCmd.Flags().BoolVar(&confStdin, "confstdin", confStdin, "config will be read from stdin if set") RootCmd.Flags().StringVarP(&confPath, "confpath", "c", confPath, "config path") - var helpflag bool - RootCmd.SetUsageTemplate(help) - RootCmd.PersistentFlags().BoolVarP(&helpflag, "help", "h", false, "help for dmsgpty-host") - RootCmd.SetHelpCommand(&cobra.Command{Hidden: true}) - RootCmd.PersistentFlags().MarkHidden("help") //nolint + } // RootCmd contains commands for dmsgpty-host var RootCmd = &cobra.Command{ Use: "host", - Short: "runs a standalone dmsgpty-host instance", + Short: "DMSG host for pseudoterminal command line interface", Long: ` ┌┬┐┌┬┐┌─┐┌─┐┌─┐┌┬┐┬ ┬ ┬ ┬┌─┐┌─┐┌┬┐ │││││└─┐│ ┬├─┘ │ └┬┘───├─┤│ │└─┐ │ - ─┴┘┴ ┴└─┘└─┘┴ ┴ ┴ ┴ ┴└─┘└─┘ ┴ `, + ─┴┘┴ ┴└─┘└─┘┴ ┴ ┴ ┴ ┴└─┘└─┘ ┴ + ` + "DMSG host for pseudoterminal command line interface", SilenceErrors: true, SilenceUsage: true, DisableSuggestions: true, @@ -158,34 +154,11 @@ var RootCmd = &cobra.Command{ // Execute executes the root command. func Execute() { - cc.Init(&cc.Config{ - RootCmd: RootCmd, - Headings: cc.HiBlue + cc.Bold, //+ cc.Underline, - Commands: cc.HiBlue + cc.Bold, - CmdShortDescr: cc.HiBlue, - Example: cc.HiBlue + cc.Italic, - ExecName: cc.HiBlue + cc.Bold, - Flags: cc.HiBlue + cc.Bold, - //FlagsDataType: cc.HiBlue, - FlagsDescr: cc.HiBlue, - NoExtraNewlines: true, - NoBottomNewline: true, - }) if err := RootCmd.Execute(); err != nil { os.Exit(1) } } -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" - func configFromJSON(conf dmsgpty.Config) (dmsgpty.Config, error) { var jsonConf dmsgpty.Config diff --git a/vendor/github.com/skycoin/dmsg/cmd/dmsgpty-ui/commands/dmsgpty-ui.go b/vendor/github.com/skycoin/dmsg/cmd/dmsgpty-ui/commands/dmsgpty-ui.go new file mode 100644 index 0000000000..49b828e5a7 --- /dev/null +++ b/vendor/github.com/skycoin/dmsg/cmd/dmsgpty-ui/commands/dmsgpty-ui.go @@ -0,0 +1,72 @@ +// Package commands cmd/dmsgpty-ui/commands/root.go +package commands + +import ( + "log" + "net/http" + "os" + "time" + + "github.com/sirupsen/logrus" + "github.com/skycoin/skywire-utilities/pkg/buildinfo" + "github.com/spf13/cobra" + + "github.com/skycoin/dmsg/pkg/dmsgpty" +) + +var ( + hostNet = dmsgpty.DefaultCLINet + hostAddr = dmsgpty.DefaultCLIAddr() + addr = ":8080" + conf = dmsgpty.DefaultUIConfig() +) + +func init() { + RootCmd.Flags().StringVar(&hostNet, "hnet", hostNet, "dmsgpty host network name") + RootCmd.Flags().StringVar(&hostAddr, "haddr", hostAddr, "dmsgpty host network address") + RootCmd.Flags().StringVar(&addr, "addr", addr, "network address to serve UI on") + RootCmd.Flags().StringVar(&conf.CmdName, "cmd", conf.CmdName, "command to run when initiating pty") + RootCmd.Flags().StringArrayVar(&conf.CmdArgs, "arg", conf.CmdArgs, "command arguments to include when initiating pty") +} + +// RootCmd contains commands to start a dmsgpty-ui server for a dmsgpty-host +var RootCmd = &cobra.Command{ + Use: "ui", + Short: "DMSG pseudoterminal GUI", + Long: ` + ┌┬┐┌┬┐┌─┐┌─┐┌─┐┌┬┐┬ ┬ ┬ ┬┬ + │││││└─┐│ ┬├─┘ │ └┬┘───│ ││ + ─┴┘┴ ┴└─┘└─┘┴ ┴ ┴ └─┘┴ + ` + "DMSG pseudoterminal GUI", + Run: func(cmd *cobra.Command, args []string) { + if _, err := buildinfo.Get().WriteTo(log.Writer()); err != nil { + log.Printf("Failed to output build info: %v", err) + } + + ui := dmsgpty.NewUI(dmsgpty.NetUIDialer(hostNet, hostAddr), conf) + logrus. + WithField("addr", addr). + Info("Serving.") + + srv := &http.Server{ + ReadTimeout: 3 * time.Second, + WriteTimeout: 3 * time.Second, + IdleTimeout: 30 * time.Second, + ReadHeaderTimeout: 3 * time.Second, + Addr: addr, + Handler: ui.Handler(nil), + } + + err := srv.ListenAndServe() + logrus. + WithError(err). + Info("Stopped serving.") + }, +} + +// Execute executes the root command. +func Execute() { + if err := RootCmd.Execute(); err != nil { + os.Exit(1) + } +} diff --git a/vendor/github.com/skycoin/dmsg/cmd/dmsgpty-ui/commands/root.go b/vendor/github.com/skycoin/dmsg/cmd/dmsgpty-ui/commands/root.go deleted file mode 100644 index 4cc4987e71..0000000000 --- a/vendor/github.com/skycoin/dmsg/cmd/dmsgpty-ui/commands/root.go +++ /dev/null @@ -1,100 +0,0 @@ -// Package commands cmd/dmsgpty-ui/commands/root.go -package commands - -import ( - "log" - "net/http" - "os" - "time" - - cc "github.com/ivanpirog/coloredcobra" - "github.com/sirupsen/logrus" - "github.com/skycoin/skywire-utilities/pkg/buildinfo" - "github.com/spf13/cobra" - - "github.com/skycoin/dmsg/pkg/dmsgpty" -) - -var ( - hostNet = dmsgpty.DefaultCLINet - hostAddr = dmsgpty.DefaultCLIAddr() - addr = ":8080" - conf = dmsgpty.DefaultUIConfig() -) - -func init() { - RootCmd.PersistentFlags().StringVar(&hostNet, "hnet", hostNet, "dmsgpty host network name") - RootCmd.PersistentFlags().StringVar(&hostAddr, "haddr", hostAddr, "dmsgpty host network address") - RootCmd.PersistentFlags().StringVar(&addr, "addr", addr, "network address to serve UI on") - RootCmd.PersistentFlags().StringVar(&conf.CmdName, "cmd", conf.CmdName, "command to run when initiating pty") - RootCmd.PersistentFlags().StringArrayVar(&conf.CmdArgs, "arg", conf.CmdArgs, "command arguments to include when initiating pty") - var helpflag bool - RootCmd.SetUsageTemplate(help) - RootCmd.PersistentFlags().BoolVarP(&helpflag, "help", "h", false, "help for dmsgpty-ui") - RootCmd.SetHelpCommand(&cobra.Command{Hidden: true}) - RootCmd.PersistentFlags().MarkHidden("help") //nolint -} - -// RootCmd contains commands to start a dmsgpty-ui server for a dmsgpty-host -var RootCmd = &cobra.Command{ - Use: "ui", - Short: "hosts a UI server for a dmsgpty-host", - Long: ` - ┌┬┐┌┬┐┌─┐┌─┐┌─┐┌┬┐┬ ┬ ┬ ┬┬ - │││││└─┐│ ┬├─┘ │ └┬┘───│ ││ - ─┴┘┴ ┴└─┘└─┘┴ ┴ ┴ └─┘┴`, - Run: func(cmd *cobra.Command, args []string) { - if _, err := buildinfo.Get().WriteTo(log.Writer()); err != nil { - log.Printf("Failed to output build info: %v", err) - } - - ui := dmsgpty.NewUI(dmsgpty.NetUIDialer(hostNet, hostAddr), conf) - logrus. - WithField("addr", addr). - Info("Serving.") - - srv := &http.Server{ - ReadTimeout: 3 * time.Second, - WriteTimeout: 3 * time.Second, - IdleTimeout: 30 * time.Second, - ReadHeaderTimeout: 3 * time.Second, - Addr: addr, - Handler: ui.Handler(nil), - } - - err := srv.ListenAndServe() - logrus. - WithError(err). - Info("Stopped serving.") - }, -} - -// Execute executes the root command. -func Execute() { - cc.Init(&cc.Config{ - RootCmd: RootCmd, - Headings: cc.HiBlue + cc.Bold, //+ cc.Underline, - Commands: cc.HiBlue + cc.Bold, - CmdShortDescr: cc.HiBlue, - Example: cc.HiBlue + cc.Italic, - ExecName: cc.HiBlue + cc.Bold, - Flags: cc.HiBlue + cc.Bold, - //FlagsDataType: cc.HiBlue, - FlagsDescr: cc.HiBlue, - NoExtraNewlines: true, - NoBottomNewline: true, - }) - if err := RootCmd.Execute(); err != nil { - os.Exit(1) - } -} - -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/vendor/github.com/skycoin/dmsg/cmd/dmsgweb/commands/dmsgweb.go b/vendor/github.com/skycoin/dmsg/cmd/dmsgweb/commands/dmsgweb.go index 9571df26a8..eefb41feaf 100644 --- a/vendor/github.com/skycoin/dmsg/cmd/dmsgweb/commands/dmsgweb.go +++ b/vendor/github.com/skycoin/dmsg/cmd/dmsgweb/commands/dmsgweb.go @@ -18,7 +18,6 @@ import ( "github.com/confiant-inc/go-socks5" "github.com/gin-gonic/gin" - cc "github.com/ivanpirog/coloredcobra" "github.com/skycoin/skywire-utilities/pkg/buildinfo" "github.com/skycoin/skywire-utilities/pkg/cipher" "github.com/skycoin/skywire-utilities/pkg/cmdutil" @@ -89,21 +88,17 @@ func init() { sk.Set(os.Getenv("DMSGGET_SK")) //nolint } RootCmd.Flags().VarP(&sk, "sk", "s", "a random key is generated if unspecified\n\r") - var helpflag bool - RootCmd.SetUsageTemplate(help) - RootCmd.PersistentFlags().BoolVarP(&helpflag, "help", "h", false, "help for dmsgweb") - RootCmd.SetHelpCommand(&cobra.Command{Hidden: true}) - RootCmd.PersistentFlags().MarkHidden("help") //nolint } // RootCmd contains the root command for dmsgweb var RootCmd = &cobra.Command{ - Use: "dmsgweb", - Short: "access websites over dmsg", + Use: "web", + Short: "DMSG resolving proxy & browser client", Long: ` ┌┬┐┌┬┐┌─┐┌─┐┬ ┬┌─┐┌┐ │││││└─┐│ ┬│││├┤ ├┴┐ - ─┴┘┴ ┴└─┘└─┘└┴┘└─┘└─┘`, + ─┴┘┴ ┴└─┘└─┘└┴┘└─┘└─┘ + ` + "DMSG resolving proxy & browser client - access websites over dmsg", SilenceErrors: true, SilenceUsage: true, DisableSuggestions: true, @@ -363,30 +358,7 @@ const ( // Execute executes root CLI command. func Execute() { - cc.Init(&cc.Config{ - RootCmd: RootCmd, - Headings: cc.HiBlue + cc.Bold, //+ cc.Underline, - Commands: cc.HiBlue + cc.Bold, - CmdShortDescr: cc.HiBlue, - Example: cc.HiBlue + cc.Italic, - ExecName: cc.HiBlue + cc.Bold, - Flags: cc.HiBlue + cc.Bold, - //FlagsDataType: cc.HiBlue, - FlagsDescr: cc.HiBlue, - 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/vendor/modules.txt b/vendor/modules.txt index a12a641373..c0fcd323b1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -442,7 +442,7 @@ github.com/rs/cors ## explicit; go 1.13 github.com/sirupsen/logrus github.com/sirupsen/logrus/hooks/syslog -# github.com/skycoin/dmsg v1.3.17 +# github.com/skycoin/dmsg v1.3.18-0.20240210174503-ecde4c538de6 ## explicit; go 1.21 github.com/skycoin/dmsg/cmd/dmsg-discovery/commands github.com/skycoin/dmsg/cmd/dmsg-server/commands