Error on non-flag commandline arguments

- Added minor cmdline parsing logic change to bail on
  unconsumed arguments. Fixes #1821
This commit is contained in:
Dave Rawks 2016-07-19 16:33:34 -07:00
parent 40f8da699e
commit 00ea36cdbe
1 changed files with 4 additions and 1 deletions

View File

@ -242,10 +242,13 @@ func init() {
func parse(args []string) error {
err := cfg.fs.Parse(args)
if err != nil {
if err != nil || len(cfg.fs.Args()) != 0 {
if err != flag.ErrHelp {
log.Errorf("Invalid command line arguments. Help: %s -h", os.Args[0])
}
if err == nil {
err = fmt.Errorf("Non-flag argument on command line: %q", cfg.fs.Args()[0])
}
return err
}