@cryptotaxi247 / kubo / commits / a2d06b5f9

cmds2: errHelpRequested error

Juan Batiz-Benet committed Nov 12, 2014 at 03:54 UTC a2d06b5f9a41a256558f19e848de94844dc3a545
1 file changed +10
cmd/ipfs2/main.go
+10
@@ -25,6 +25,9 @@ import (
25 // log is the command logger
26 var log = u.Logger("cmd/ipfs")
27
28 +// signal to output help
29 +var errHelpRequested = errors.New("Help Requested")
30 +
31 const (
32 cpuProfile = "ipfs.cpuprof"
33 heapProfile = "ipfs.memprof"
@@ -45,6 +48,10 @@ func run() error {
48 args := os.Args[1:]
49 req, root, err := createRequest(args)
50 if err != nil {
51 + // when the error is errOutputHelp, just exit gracefully.
52 + if err == errHelpRequested {
53 + return nil
54 + }
55 return err
56 }
57
@@ -135,6 +142,9 @@ func handleParseError(req cmds.Request, root *cmds.Command, cmd *cmds.Command, p
142 if err != nil {
143 return err
144 }
145 +
146 + // override the error to avoid signaling other issues.
147 + parseError = errHelpRequested
148 }
149
150 // if the -help flag wasn't specified, show the error message