10000 Unable to use options with alias "-i" or "-o" · Issue #1382 · dotnet/command-line-api · GitHub
[go: up one dir, main page]

Skip to content
Unable to use options with alias "-i" or "-o" #1382
Closed
@peteraritchie

Description

@peteraritchie

When I try this code, the command handler gets no value for the first argument and thus causes an assertion exception:

		private static int Main(string[] args)
		{
			var inputOption = new Option<string>(
				new string[] { "--input", "-i" }, "first");

			var testCommand = new Command("test", "test summary")
			{
				inputOption
			};
			testCommand.Handler = CommandHandler.Create<string>(f
				=> Debug.Assert(!string.IsNullOrWhiteSpace(f)));

			var rootCommand = new RootCommand()
			{
				testCommand
			};

			return rootCommand.InvokeAsync(args).Result;
		}

args: test -i 1

If I change only the alias names when creating an Option to this:

			var inputOption = new Option<string>(
				new string[] { "--fnput", "-f" }, "first");

It works fine

args: test -f 1

Am I missing something obvious?

Version: 2.0.0-beta1.21308.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0