Skip to content

Commit 871d908

Browse files
committed
Add a more helpful error message when unkown options are encountered
1 parent ee0de3b commit 871d908

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

docopt.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,15 @@ func parse(doc string, argv []string, help bool, version string, optionsFirst bo
181181
return
182182
}
183183

184-
err = newUserError("")
184+
if len(*left) > 0 {
185+
var left_names []string
186+
for _, l := range(*left) {
187+
left_names = append(left_names, l.name)
188+
}
189+
err = newUserError(fmt.Sprintf("Unknown option(s): %s", strings.Join(left_names, ", ")))
190+
} else {
191+
err = newUserError("")
192+
}
185193
output = handleError(err, usage)
186194
return
187195
}

0 commit comments

Comments
 (0)