--version not showing version when default command set
Information
- OS: [all]
- Version: [0.46.0]
To Reproduce
- Set default command using
SetDefaultCommand - Run
mycmd --version - Version not shown
Expected behavior Shows version instead of executing default command
Additional context
FYI. I've nearly fixed this and will submit a PR soon (likely in the coming weeks).
I don‘t think this bug has fixed. When I using SetDefaultCommand, -v is still not work. spectre.console version: 0.49.1
I'll take a look @my522cn, please be on hand if I need help reproducing it.
Unfortunately it's still broken in 0.49.1 @my522cn
Here is my command and application:
using Spectre.Console;
using Spectre.Console.Cli;
public class EmptyCommand : Command<EmptyCommandSettings>
{
public override int Execute(CommandContext context, EmptyCommandSettings settings)
{
AnsiConsole.MarkupLine("Hello world");
return 0;
}
}
public static class Program
{
public static int Main(string[] args)
{
var app = new CommandApp();
app.SetDefaultCommand<EmptyCommand>();
app.Configure(config =>
{
config.SetApplicationVersion("1.0");
});
return app.Run(args);
}
}
The default command is executed, not the version shown:
Expected behavior Shows version instead of executing default command
I don‘t think this bug has fixed. When I using SetDefaultCommand, -v is still not work. spectre.console version: 0.49.1
0.49.0 Still not work
I don‘t think this bug has fixed. When I using SetDefaultCommand, -v is still not work. spectre.console version: 0.49.1
0.49.0 Still not work
It's not fixed, however once the PR above (#1663) is merged, it will be!
As a workaround, add this to the start of the Execute{Async} method of the default command:
if ( context.Arguments.Contains( "--version" )
|| context.Arguments.Contains( "-v" ) )
{
AnsiConsole.WriteLine( "Version info here" );
return 0;
}
We are unfortunately experiencing a lack of maintainer bandwidth to review PR's, otherwise this would be fixed by the attached PR @KnapSac
That's unfortunate. Luckily I can work around this issue for now, so no worries!