From 00ea36cdbe3b372b0223a3667b6108bdac181d5e Mon Sep 17 00:00:00 2001 From: Dave Rawks Date: Tue, 19 Jul 2016 16:33:34 -0700 Subject: [PATCH] Error on non-flag commandline arguments - Added minor cmdline parsing logic change to bail on unconsumed arguments. Fixes #1821 --- cmd/prometheus/config.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/prometheus/config.go b/cmd/prometheus/config.go index f2b3978b6..dea76a1e5 100644 --- a/cmd/prometheus/config.go +++ b/cmd/prometheus/config.go @@ -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 }