cmd/ipfs: Fixed bug where handleParseError sets error to nil
Matt Bell committed
Nov 12, 2014 at 01:50 UTC
78bc748342dfe851cd3849e39d5200b391d2c4ee
1 file changed
+5
-4
cmd/ipfs2/main.go
+5
-4
@@ -92,7 +92,7 @@ func createRequest(args []string) (cmds.Request, *cmds.Command, error) {
92
// handle parse error (which means the commandline input was wrong,
93
// e.g. incorrect number of args, or nonexistent subcommand)
94
if err != nil {
95
- return nil, nil, handleParseError(req, root, cmd, path)
95
+ return nil, nil, handleParseError(req, root, cmd, path, err)
96
}
97
98
configPath, err := getConfigRoot(req)
@@ -121,11 +121,12 @@ func createRequest(args []string) (cmds.Request, *cmds.Command, error) {
121
return req, root, nil
122
}
123
124
-func handleParseError(req cmds.Request, root *cmds.Command, cmd *cmds.Command, path []string) (err error) {
124
+func handleParseError(req cmds.Request, root *cmds.Command, cmd *cmds.Command, path []string, parseError error) error {
125
var longHelp, shortHelp bool
126
127
if req != nil {
128
// help and h are defined in the root. We expect them to be bool.
129
+ var err error
130
longHelp, _, err = req.Option("help").Bool()
131
if err != nil {
132
return err
@@ -141,7 +142,7 @@ func handleParseError(req cmds.Request, root *cmds.Command, cmd *cmds.Command, p
142
// (this means there was an option or argument error)
143
if path != nil && len(path) > 0 {
144
if !longHelp && !shortHelp {
144
- fmt.Printf(errorFormat, err)
145
+ fmt.Printf(errorFormat, parseError)
146
}
147
}
148
@@ -160,7 +161,7 @@ func handleParseError(req cmds.Request, root *cmds.Command, cmd *cmds.Command, p
161
if htErr != nil {
162
fmt.Println(htErr)
163
}
163
- return err
164
+ return parseError
165
}
166
167
func handleHelpOption(req cmds.Request, root *cmds.Command) (helpTextDisplayed bool, err error) {