A `boolean` flag followed by a positional argument leads the the error `Flags cannot be assigned a value.`
See original GitHub issueInformation
- 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
Issue Analytics
- State:
- Created a year ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Declaring Arguments, Options, and Flags | Documentation
Arguments are values given by a user and are read in order from first to ... Option and flag names are derived from...
Read more >How to pass boolean arguments to go flags
As @fabrizioM said, boolean flags are a particular case because the presence of such a flag without an argument implies that the flag...
Read more >Arg in clap - Rust
Pro tip: Flags (i.e. not positional, or arguments that take values) shouldn't be required by default. This is because if a flag were...
Read more >ArgumentParser — Chapel Documentation 1.31
defaultValue – a value to assign the argument when a flag is not required, and a is not entered on the command line....
Read more >Using Python Optional Arguments When Defining Functions
In this tutorial, you'll learn about Python optional arguments and how to define functions with default values. You'll also learn how to create...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sandreas -df is already supported.
Excellent write up and example @sandreas. I plan to fix the other issue, which is one step forward and will let me learn the parser and improve code coverage. Then come back to this issue.