mirror of
https://github.com/prometheus/prometheus
synced 2024-12-26 00:23:18 +00:00
Error on non-flag commandline arguments
- Added minor cmdline parsing logic change to bail on unconsumed arguments. Fixes #1821
This commit is contained in:
parent
56151e57ba
commit
40b9666479
@ -245,10 +245,13 @@ func init() {
|
|||||||
|
|
||||||
func parse(args []string) error {
|
func parse(args []string) error {
|
||||||
err := cfg.fs.Parse(args)
|
err := cfg.fs.Parse(args)
|
||||||
if err != nil {
|
if err != nil || len(cfg.fs.Args()) != 0 {
|
||||||
if err != flag.ErrHelp {
|
if err != flag.ErrHelp {
|
||||||
log.Errorf("Invalid command line arguments. Help: %s -h", os.Args[0])
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user