Skip to content

A boolean flag followed by a positional argument leads the the error Flags cannot be assigned a value. #825

@sandreas

Description

@sandreas

Information

  • OS: macOS
  • Version: 0.43.0
  • Terminal: macOS Term

Describe the bug
A combination of a boolean flag and a positional argument leads the the error Flags cannot be assigned a value., which is wrong in my opinion.

To Reproduce
Use the following settings:

// ...
    [Description("Input files or folders")]
    [CommandArgument(0, "[input]")]
    public string[] Input { get; set; } = Array.Empty<string>();

    [CommandOption("--dry-run")] public bool DryRun { get; init; } = false;
// ...

And call the app like this:

myapp --dry-run "my-input-folder/"

Expected behavior
As --dry-run is a flag, I would expect spectre.console to handle the fact, taht there is a positional argument in the settings and parse this correctly. In my opinion this should work without error messages.

Workaround
Putting the flag at the end works like expected:

myapp "my-input-folder/" --dry-run

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Done 🚀

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions