-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* combined visor + cli binaries * add setup-node as a subcommand of the skywire binary * add comments for exported variables * add comments for exported variables * make format
- Loading branch information
Showing
5 changed files
with
101 additions
and
26 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
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,6 +1,6 @@ | ||
// /* cmd/skywire-visor/skywire-visor.go | ||
// /* cmd/skywire/skywire.go | ||
/* | ||
skywire visor | ||
skywire | ||
*/ | ||
package main | ||
|
||
|
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,73 @@ | ||
// /* cmd/skywire-visor/skywire-visor.go | ||
/* | ||
skywire visor | ||
*/ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
cc "github.com/ivanpirog/coloredcobra" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/skycoin/skywire-utilities/pkg/buildinfo" | ||
setupnode "github.com/skycoin/skywire/cmd/setup-node/commands" | ||
skywirecli "github.com/skycoin/skywire/cmd/skywire-cli/commands" | ||
"github.com/skycoin/skywire/pkg/visor" | ||
) | ||
|
||
func init() { | ||
rootCmd.AddCommand( | ||
visor.RootCmd, | ||
skywirecli.RootCmd, | ||
setupnode.RootCmd, | ||
) | ||
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 | ||
rootCmd.CompletionOptions.DisableDefaultCmd = true | ||
|
||
} | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "skywire", | ||
Long: ` | ||
┌─┐┬┌─┬ ┬┬ ┬┬┬─┐┌─┐ | ||
└─┐├┴┐└┬┘││││├┬┘├┤ | ||
└─┘┴ ┴ ┴ └┴┘┴┴└─└─┘`, | ||
SilenceErrors: true, | ||
SilenceUsage: true, | ||
DisableSuggestions: true, | ||
DisableFlagsInUseLine: true, | ||
Version: buildinfo.Version(), | ||
} | ||
|
||
func main() { | ||
cc.Init(&cc.Config{ | ||
RootCmd: rootCmd, | ||
Headings: cc.HiBlue + cc.Bold, | ||
Commands: cc.HiBlue + cc.Bold, | ||
CmdShortDescr: cc.HiBlue, | ||
Example: cc.HiBlue + cc.Italic, | ||
ExecName: cc.HiBlue + cc.Bold, | ||
Flags: cc.HiBlue + cc.Bold, | ||
FlagsDescr: cc.HiBlue, | ||
NoExtraNewlines: true, | ||
NoBottomNewline: true, | ||
}) | ||
|
||
if err := rootCmd.Execute(); err != nil { | ||
fmt.Println(err) | ||
} | ||
} | ||
|
||
const help = "{{if gt (len .Aliases) 0}}" + | ||
"{{.NameAndAliases}}{{end}}{{if .HasAvailableSubCommands}}" + | ||
"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" |
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