When using Commands can't use Option with short name with more than 1 letter.
See original GitHub issueDescribe the bug When using Commands can’t use Option with short name with more than 1 letter.
To Reproduce Steps to reproduce the behavior: 1.Create main class:
[Subcommand(typeof(SCmd1))]
[Command(Name = "Cmd")]
class Program
{
public static int Main(string[] args)
=> CommandLineApplication.Execute<Program>(args);
public void OnExecute(CommandLineApplication app)
{
app.ShowHelp();
}
}
- Create command class:
[Command("SubCommand1", "SC1")]
class SCmd1
{
[Option(Description = "first option", ShortName = "o1", LongName = "option-1")]
public string Option1{ get; } = null;
public void OnExecute(CommandLineApplication app)
{
...
}
- Run command
Program SC1 -o1 whatever
- Get error
Unrecognized option '-o'
Expected behavior I would expect to recognize the option “o1” and to set the property “Option1” with the value “whatever”.
Screenshots
>JsonSqueezer sqz
Usage: JSONSqueezer squeeze [options]
Options:
-i|--input <INPUT_PATH> Input JSON file to be sqeezed (requiered).
-cf|--custom-fields-path <CUSTOM_FIELDS_PATH> A JSON file with a list of paths to extract to the User extraction path.
>JsonSqueezer sqz -cf EnvironementConfiguration.conf.json -i "Export.json"
Specify --help for a list of available options and commands.
Unrecognized option '-c'
Additional context Im using version 2.3.3
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Command-line Options: Should short options be restricted ...
My question is, should I continue to use only a single character for short form command-line options in Python? Is that what users...
Read more >Why are there short and long alternatives for command line ...
Most unixoid commands feature short and long alternatives for command line options, like ls -a and ls --all , or ls -A and...
Read more >4.2.2.1 Using Options on the Command Line
An option argument begins with one dash or two dashes, depending on whether it is a short form or long form of the...
Read more >Defining commands/abbreviations that contain numbers
Recommendation: Either choose another mechanism (such as \DefineRemark above), or choose another name for your macro, one that contains only ...
Read more >Command-line syntax overview for System.CommandLine
Short names Make names for commands, options, and arguments as short and easy to spell as possible. For example, if class is...
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 Free
Top 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
I did not realize it was on your own feed. It works as expected now.
Thanks for your help Nate and keep up with the good work!
Thanks for confirming. I’ll push an update to nuget.org in a week or so. I’m waiting to see if anything else is needed in the next patch.