question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When using Commands can't use Option with short name with more than 1 letter.

See original GitHub issue

Describe 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();
        }
    }
  1. 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)
        {
            ...
        }
  1. Run command Program SC1 -o1 whatever
  2. 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:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
axelwasscommented, Mar 19, 2019

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!

0reactions
natemcmastercommented, Mar 19, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found