Make -v|--version opt-in

We added an automatic version option in 0.49. We did this with good
intentions, but forgot that people might already use --version
as an option for a root command.

This commit makes -v|--version completely opt-in.
This commit is contained in:
Patrik Svensson
2024-04-25 19:34:07 +02:00
committed by Patrik Svensson
parent 88515b7d7f
commit 3acc90e47c
36 changed files with 276 additions and 211 deletions

View File

@ -3,6 +3,7 @@ namespace Spectre.Console.Cli;
internal sealed class CommandModel : ICommandContainer, ICommandModel
{
public string? ApplicationName { get; }
public string? ApplicationVersion { get; }
public ParsingMode ParsingMode { get; }
public IList<CommandInfo> Commands { get; }
public IList<string[]> Examples { get; }
@ -20,9 +21,10 @@ internal sealed class CommandModel : ICommandContainer, ICommandModel
IEnumerable<string[]> examples)
{
ApplicationName = settings.ApplicationName;
ApplicationVersion = settings.ApplicationVersion;
ParsingMode = settings.ParsingMode;
Commands = new List<CommandInfo>(commands ?? Array.Empty<CommandInfo>());
Examples = new List<string[]>(examples ?? Array.Empty<string[]>());
Commands = new List<CommandInfo>(commands);
Examples = new List<string[]>(examples);
}
/// <summary>