Support options before arguments
See original GitHub issueEspecially for Unix/Linux platforms, the convention is usually to provide options before arguments:
Usage: grep [OPTION]... PATTERN [FILE]...
Usage: tar [OPTION...] [FILE]...
systemctl [OPTIONS...] {COMMAND} ...
Using boolean options before arguments currently gets incorrectly interpreted as assigning a value to the option flag. Would be good to support this ordering (preferably alongside existing behaviour).
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Handling command line options before and after an ...
So far I've been using getopt_long to parse options for a command line C program. Is there a way to stop getopt_long parsing...
Read more >Support options before arguments · Issue #193
This issue is occuring due to the way that CommandTreeParser is handling Options, namely peeking ahead to the next argument to determine what...
Read more >How to introduce support for command line options in a ...
Implement ordinary command line parsing using getopts . If that parsing is triggered at all, set a flag to keep track of this...
Read more >Conventions for Command Line Options
The next simplest case are short options that take arguments. The argument follows the option. program -i input.txt -o output.txt. The space is ......
Read more >Adding arguments and options to your Bash scripts
Try putting the parameters in a different order to see how that works. These parameters are positional, and that is a key consideration....
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
This issue is occuring due to the way that CommandTreeParser is handling Options, namely peeking ahead to the next argument to determine what to do.
The following image is when I’ve specified the following on the command line
--version --somethingelse
and it’s currently parsing the --version Option. you can see that it’s peeked ahead and discovered another Option:It knows to correctly ignore the following
somethingelse
Option and just proceed with the ‘No value?’ code further on.When I specify the following on the command line
--version somethingelse
, then when it is parsing the --version Option, it peeks ahead and discovers something following it of TokenKind String:CommandTreeParser.ParseOptionValue proceeds to attempt to set the --version Option to this value, unsuccessfully:
For @woutervanranst 's example above to work correctly,
restore --keep-pointers c:\Users\Wouter\Documents\Test
I guess the CommandTreeParser needs to
--keep-pointers
is a flag (ie. boolean value specified on the command settings class)c:\Users\Wouter\Documents\Test
on the next pass (which should be handled here I suspect:)--keep-pointers
option value toc:\Users\Wouter\Documents\Test
This issue can be closed/marked as complete @patriksvensson, now that PR https://github.com/spectreconsole/spectre.console/pull/1048 has been successfully merged.