-
-
Notifications
You must be signed in to change notification settings - Fork 512
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
Default --version option is not working for subcommands #1567
Comments
The issue does not occur when I enable StrictParsing, but I believe this behavior should still be fixed for normal, default case. |
I feel like I have a similar issue when using a "default command". Main file module CommitLinter.Main
open Spectre.Console.Cli
open CommitLinter.Commands
[<EntryPoint>]
let main args =
let app = CommandApp<GenerateCommand>()
app
.WithDescription("Generate changelog based on the Git history.")
.Configure(fun config ->
config.Settings.ApplicationName <- "changelog-gen" // Find a name
)
app.Run(args) Command file namespace CommitLinter.Commands
open Spectre.Console
open Spectre.Console.Cli
open System.ComponentModel
open System.IO
type GenerateSettings() =
inherit CommandSettings()
[<CommandOption("-c|--config")>]
[<Description("Path to the configuration file")>]
member val Config: string option = None with get, set
type GenerateCommand() =
inherit Command<GenerateSettings>()
interface ICommandLimiter<GenerateSettings>
override __.Execute(context, settings) =
printfn "Generate command"
0 Then if I run Use strict parsing doesn't help, it only report an issue because Or perhaps my issue was related to #1216? |
Hello @MangelMaxime, your issue is #1216, which I have validated as still occurring in 0.49.1 |
Unfortunately it's still broken in 0.49.1 @ericsuhong 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.Configure(config =>
{
config.SetApplicationVersion("1.0");
config.AddCommand<EmptyCommand>("hello");
});
return app.Run(args);
}
} Help for the subcommand shows the version option, but when the version option is specified, the subcommand executes instead: Expected behaviour
|
Information
Describe the bug
--version option is working for the root command as expected.
However, when I run --version option for any subcommands, it does not print version and --version option is ignored.
This is confusing because --help option displays --version as a valid option for all subcommands by default.
To Reproduce
Run any spectre subcommands with --version.
Expected behavior
--version MUST NOT be displayed by default as part of --help output for subcommands that do not have explicitly defined --version option.
Please upvote 👍 this issue if you are interested in it.
The text was updated successfully, but these errors were encountered: