Skip to content

Commit

Permalink
Merge pull request #238 from berrange/virtctl
Browse files Browse the repository at this point in the history
Don't look for virtctl command if none is given
  • Loading branch information
rmohr committed Jun 6, 2017
2 parents e2bc7b6 + 283d6c1 commit fea9b05
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions cmd/virtctl/virtctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,27 @@ func main() {
"convert-spec": convert.NewConvertCommand(),
}

for cmd, app := range registry {
f := app.FlagSet()
f.Bool("help", false, "Print usage.")
f.MarkHidden("help")
f.Usage = func() {
fmt.Fprint(os.Stderr, app.Usage())
}
if len(os.Args) > 1 {
for cmd, app := range registry {
f := app.FlagSet()
f.Bool("help", false, "Print usage.")
f.MarkHidden("help")
f.Usage = func() {
fmt.Fprint(os.Stderr, app.Usage())
}

if os.Args[1] != cmd {
continue
}
flags, err := Parse(f)
if os.Args[1] != cmd {
continue
}
flags, err := Parse(f)

h, _ := flags.GetBool("help")
if h || err != nil {
f.Usage()
return
h, _ := flags.GetBool("help")
if h || err != nil {
f.Usage()
return
}
os.Exit(app.Run(flags))
}
os.Exit(app.Run(flags))
}

Usage()
Expand Down

0 comments on commit fea9b05

Please sign in to comment.