Permalink
Browse files

Fix -h handling, add version to help.

  • Loading branch information...
1 parent fc32ade commit 718c181eb90f7ea96cf44319126ec10aae4cca67 @AlekSi committed Feb 23, 2013
Showing with 7 additions and 3 deletions.
  1. +7 −3 nut/main.go
View
@@ -51,6 +51,7 @@ func (c *Command) Usage() {
var Commands = []*Command{cmdCheck, cmdGenerate, cmdGet, cmdInstall, cmdPack, cmdPublish, cmdUnpack}
var usageTemplate = template.Must(template.New("top").Parse(`Nut is a tool for managing versioned Go source code packages.
+Version 0.3.dev.
Usage:
@@ -68,7 +69,7 @@ Use "nut help [command]" for more information about a command.
func help(args ...string) {
if len(args) == 0 {
flag.Usage()
- os.Exit(0)
+ os.Exit(2)
}
if len(args) != 1 {
log.Print("usage: nut help [command]\n\nToo many arguments given.")
@@ -79,7 +80,7 @@ func help(args ...string) {
for _, cmd := range Commands {
if cmd.Name() == arg {
cmd.Usage()
- os.Exit(0)
+ os.Exit(2)
}
}
@@ -106,7 +107,10 @@ func main() {
for _, cmd := range Commands {
if cmd.Name() == args[0] {
- cmd.Flag.Usage = func() { cmd.Usage() }
+ cmd.Flag.Usage = func() {
+ cmd.Usage()
+ os.Exit(2)
+ }
cmd.Flag.Parse(args[1:])
cmd.Run(cmd)
os.Exit(0)

0 comments on commit 718c181

Please sign in to comment.