Skip to content

Flags are ignored after positional arguments (v4 alpha) #124

@antoineco

Description

@antoineco

While experimenting with v4.0.0-alpha.4 for a toy project, I noticed that flags located after any positional argument were ignored during parsing.

The issue can be reproduced with the objectctl example on the latest tag: https://github.com/peterbourgon/ff/tree/v4.0.0-alpha.4/examples/objectctl

Examples:

objectctl create key val --overwrite  # --overwrite is ignored (Overwrite=false)
objectctl create --overwrite key val  # --overwrite is parsed (Overwrite=true)
objectctl create key val --foo  # --foo does not yield an error
objectctl create --foo key val  # --foo yields an error ("unknown flag")

To provide more context about what I was originally trying to do:

I have a command with a global flag --verbose/-v which enables verbose logging.
Sometimes, the invocation of a command will fail and return the final error with some context, but not all. When that happens, I typically re-call the same command from my shell history, and append -v before pressing Enter to replay the actions with more details, such as the API calls that are being performed, etc.
With a command implemented with ff, I need instead to travel before the subcommand's positional arguments to add -v.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions