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

flag: allow non-flag arguments anywhere in a command line #4513

Closed
gopherbot opened this issue Dec 10, 2012 · 1 comment
Closed

flag: allow non-flag arguments anywhere in a command line #4513

gopherbot opened this issue Dec 10, 2012 · 1 comment
Milestone

Comments

@gopherbot
Copy link

by emilliken:

Currently, non-flag arguments must come after the flag arguments like:
./prog -x 1 arg1 arg2
(flag.NArg() == 2)

I'd like to be able to parse arguments like:
./prog arg1 arg2 -x 1

and have flag.NArg() return 2 instead of 4. The -x arg should also be parsed into a flag
variable.
@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 1:

This was a deliberate design decision. Historically command line
option parsers did not accepted flags everywhere on the command line.
Some now do, so there are two standards that could be used. Go uses
the original one.

Status changed to WorkingAsIntended.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants