Browse Source

simplify main.go

pull/3139/head
Frank Schroeder 8 years ago committed by Frank Schröder
parent
commit
b3aee2fc56
  1. 15
      main.go

15
main.go

@ -22,34 +22,29 @@ func main() {
func realMain() int { func realMain() int {
log.SetOutput(ioutil.Discard) log.SetOutput(ioutil.Discard)
// Get the c line args. We shortcut "--version" and "-v" to
// just show the version.
args := os.Args[1:] args := os.Args[1:]
for _, arg := range args { for _, arg := range args {
if arg == "--" { if arg == "--" {
break break
} }
if arg == "-v" || arg == "--version" { if arg == "-v" || arg == "--version" {
newArgs := make([]string, len(args)+1) args = []string{"version"}
newArgs[0] = "version"
copy(newArgs[1:], args)
args = newArgs
break break
} }
} }
// Filter out the configtest c from the help display var cmds []string
var included []string
for c := range command.Commands { for c := range command.Commands {
if c != "configtest" { if c != "configtest" {
included = append(included, c) cmds = append(cmds, c)
} }
} }
cli := &cli.CLI{ cli := &cli.CLI{
Args: args, Args: args,
Commands: command.Commands, Commands: command.Commands,
HelpFunc: cli.FilteredHelpFunc(included, cli.BasicHelpFunc("consul")), HelpFunc: cli.FilteredHelpFunc(cmds, cli.BasicHelpFunc("consul")),
} }
exitCode, err := cli.Run() exitCode, err := cli.Run()

Loading…
Cancel
Save