Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"--version option cannot be combined with other arguments." is not displayed when "--help" is also specified #2501

Open
icnocop opened this issue Nov 3, 2024 · 0 comments

Comments

@icnocop
Copy link

icnocop commented Nov 3, 2024

Hi.

Thank you for System.CommandLine.

The error message "--version option cannot be combined with other arguments." is not displayed when "--help" is also specified on the command line.

Steps to reproduce:

  1. Build console app with Program.cs:
internal class Program
{
    static async Task<int> Main(string[] args)
    {
        RootCommand rootCommand = new RootCommand();

        var option = new Option<bool>("--option1");

        rootCommand.Add(option);

        rootCommand.Handler = CommandHandler.Create(() =>
        {
            Console.WriteLine("Hello, World!");
        });

        return await rootCommand.InvokeAsync(args);
    }
}
  1. Run ConsoleApp1.exe --option1 --version
    Notice the error --version option cannot be combined with other arguments.
    This is expected behavior.

  2. Run ConsoleApp10.exe --help --version
    Notice the error is not displayed.
    Only the version is displayed.
    This is unexpected behavior; I expected the error --version option cannot be combined with other arguments..

  3. Run ConsoleApp10.exe --option1 --help --version
    Notice the error is not displayed.
    Only the version is displayed.
    This is unexpected behavior; I expected the error --version option cannot be combined with other arguments..

System.CommandLine 2.0.0-beta4.22272.1

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant