Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shell shows error and usage when given extra parameters #9095

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cmd/influx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/influxdata/influxdb/client"
"github.com/influxdata/influxdb/cmd/influx/cli"
"strings"
)

// These variables are populated via the Go linker.
Expand Down Expand Up @@ -108,6 +109,13 @@ Examples:
}
fs.Parse(os.Args[1:])

argsNotParsed := os.Args[len(os.Args)-fs.NArg():]
if len(argsNotParsed) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block should use flag.Args() instead.

https://golang.org/pkg/flag/#Arg

Args returns the non-flag command-line arguments.

fmt.Fprintf(os.Stderr, "unknown arguments: %s\n", strings.Join(argsNotParsed, " "))
fs.Usage()
os.Exit(1)
}

if c.ShowVersion {
c.Version()
os.Exit(0)
Expand Down