Skip to content

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

@axelwass

Description

@axelwass

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions