Skip to content

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

Closed
@gopherbot

Description

@gopherbot

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions