mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 00:42:51 +08:00
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:
parent
88515b7d7f
commit
3acc90e47c
@ -41,7 +41,7 @@ public class HelpProvider : IHelpProvider
|
|||||||
public bool Required { get; }
|
public bool Required { get; }
|
||||||
public string? Description { get; }
|
public string? Description { get; }
|
||||||
|
|
||||||
public HelpArgument(string name, int position, bool required, string? description)
|
private HelpArgument(string name, int position, bool required, string? description)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
Position = position;
|
Position = position;
|
||||||
@ -68,7 +68,7 @@ public class HelpProvider : IHelpProvider
|
|||||||
public string? Description { get; }
|
public string? Description { get; }
|
||||||
public object? DefaultValue { get; }
|
public object? DefaultValue { get; }
|
||||||
|
|
||||||
public HelpOption(string? @short, string? @long, string? @value, bool? valueIsOptional, string? description, object? defaultValue)
|
private HelpOption(string? @short, string? @long, string? @value, bool? valueIsOptional, string? description, object? defaultValue)
|
||||||
{
|
{
|
||||||
Short = @short;
|
Short = @short;
|
||||||
Long = @long;
|
Long = @long;
|
||||||
@ -78,17 +78,27 @@ public class HelpProvider : IHelpProvider
|
|||||||
DefaultValue = defaultValue;
|
DefaultValue = defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IReadOnlyList<HelpOption> Get(ICommandInfo? command, HelpProviderResources resources)
|
public static IReadOnlyList<HelpOption> Get(
|
||||||
|
ICommandModel model,
|
||||||
|
ICommandInfo? command,
|
||||||
|
HelpProviderResources resources)
|
||||||
{
|
{
|
||||||
var parameters = new List<HelpOption>();
|
var parameters = new List<HelpOption>
|
||||||
parameters.Add(new HelpOption("h", "help", null, null, resources.PrintHelpDescription, null));
|
{
|
||||||
|
new HelpOption("h", "help", null, null, resources.PrintHelpDescription, null),
|
||||||
|
};
|
||||||
|
|
||||||
// Version information applies to the entire application
|
// Version information applies to the entire application
|
||||||
// Include the "-v" option in the help when at the root of the command line application
|
// Include the "-v" option in the help when at the root of the command line application
|
||||||
// Don't allow the "-v" option if users have specified one or more sub-commands
|
// Don't allow the "-v" option if users have specified one or more sub-commands
|
||||||
if ((command == null || command?.Parent == null) && !(command?.IsBranch ?? false))
|
if ((command?.Parent == null) && !(command?.IsBranch ?? false))
|
||||||
{
|
{
|
||||||
parameters.Add(new HelpOption("v", "version", null, null, resources.PrintVersionDescription, null));
|
// Only show the version command if there is an
|
||||||
|
// application version set.
|
||||||
|
if (model.ApplicationVersion != null)
|
||||||
|
{
|
||||||
|
parameters.Add(new HelpOption("v", "version", null, null, resources.PrintVersionDescription, null));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parameters.AddRange(command?.Parameters.OfType<ICommandOption>().Where(o => !o.IsHidden).Select(o =>
|
parameters.AddRange(command?.Parameters.OfType<ICommandOption>().Where(o => !o.IsHidden).Select(o =>
|
||||||
@ -101,11 +111,6 @@ public class HelpProvider : IHelpProvider
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Composer NewComposer()
|
|
||||||
{
|
|
||||||
return new Composer(RenderMarkupInline);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="HelpProvider"/> class.
|
/// Initializes a new instance of the <see cref="HelpProvider"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -383,7 +388,7 @@ public class HelpProvider : IHelpProvider
|
|||||||
public virtual IEnumerable<IRenderable> GetOptions(ICommandModel model, ICommandInfo? command)
|
public virtual IEnumerable<IRenderable> GetOptions(ICommandModel model, ICommandInfo? command)
|
||||||
{
|
{
|
||||||
// Collect all options into a single structure.
|
// Collect all options into a single structure.
|
||||||
var parameters = HelpOption.Get(command, resources);
|
var parameters = HelpOption.Get(model, command, resources);
|
||||||
if (parameters.Count == 0)
|
if (parameters.Count == 0)
|
||||||
{
|
{
|
||||||
return Array.Empty<IRenderable>();
|
return Array.Empty<IRenderable>();
|
||||||
@ -420,7 +425,7 @@ public class HelpProvider : IHelpProvider
|
|||||||
|
|
||||||
if (defaultValueColumn)
|
if (defaultValueColumn)
|
||||||
{
|
{
|
||||||
columns.Add(GetOptionDefaultValue(option.DefaultValue));
|
columns.Add(GetDefaultValueForOption(option.DefaultValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
columns.Add(NewComposer().Text(option.Description?.TrimEnd('.') ?? " "));
|
columns.Add(NewComposer().Text(option.Description?.TrimEnd('.') ?? " "));
|
||||||
@ -433,60 +438,6 @@ public class HelpProvider : IHelpProvider
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IRenderable GetOptionParts(HelpOption option)
|
|
||||||
{
|
|
||||||
var composer = NewComposer();
|
|
||||||
|
|
||||||
if (option.Short != null)
|
|
||||||
{
|
|
||||||
composer.Text("-").Text(option.Short);
|
|
||||||
if (option.Long != null)
|
|
||||||
{
|
|
||||||
composer.Text(", ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
composer.Text(" ");
|
|
||||||
if (option.Long != null)
|
|
||||||
{
|
|
||||||
composer.Text(" ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (option.Long != null)
|
|
||||||
{
|
|
||||||
composer.Text("--").Text(option.Long);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (option.Value != null)
|
|
||||||
{
|
|
||||||
composer.Text(" ");
|
|
||||||
if (option.ValueIsOptional ?? false)
|
|
||||||
{
|
|
||||||
composer.Style(helpStyles?.Options?.OptionalOption ?? Style.Plain, $"[{option.Value}]");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
composer.Style(helpStyles?.Options?.RequiredOption ?? Style.Plain, $"<{option.Value}>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return composer;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IRenderable GetOptionDefaultValue(object? defaultValue)
|
|
||||||
{
|
|
||||||
return defaultValue switch
|
|
||||||
{
|
|
||||||
null => NewComposer().Text(" "),
|
|
||||||
"" => NewComposer().Text(" "),
|
|
||||||
Array { Length: 0 } => NewComposer().Text(" "),
|
|
||||||
Array array => NewComposer().Join(", ", array.Cast<object>().Select(o => NewComposer().Style(helpStyles?.Options?.DefaultValue ?? Style.Plain, o.ToString() ?? string.Empty))),
|
|
||||||
_ => NewComposer().Style(helpStyles?.Options?.DefaultValue ?? Style.Plain, defaultValue?.ToString() ?? string.Empty),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the commands section of the help information.
|
/// Gets the commands section of the help information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -556,4 +507,63 @@ public class HelpProvider : IHelpProvider
|
|||||||
{
|
{
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Composer NewComposer()
|
||||||
|
{
|
||||||
|
return new Composer(RenderMarkupInline);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IRenderable GetOptionParts(HelpOption option)
|
||||||
|
{
|
||||||
|
var composer = NewComposer();
|
||||||
|
|
||||||
|
if (option.Short != null)
|
||||||
|
{
|
||||||
|
composer.Text("-").Text(option.Short);
|
||||||
|
if (option.Long != null)
|
||||||
|
{
|
||||||
|
composer.Text(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
composer.Text(" ");
|
||||||
|
if (option.Long != null)
|
||||||
|
{
|
||||||
|
composer.Text(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (option.Long != null)
|
||||||
|
{
|
||||||
|
composer.Text("--").Text(option.Long);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (option.Value != null)
|
||||||
|
{
|
||||||
|
composer.Text(" ");
|
||||||
|
if (option.ValueIsOptional ?? false)
|
||||||
|
{
|
||||||
|
composer.Style(helpStyles?.Options?.OptionalOption ?? Style.Plain, $"[{option.Value}]");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
composer.Style(helpStyles?.Options?.RequiredOption ?? Style.Plain, $"<{option.Value}>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return composer;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Composer GetDefaultValueForOption(object? defaultValue)
|
||||||
|
{
|
||||||
|
return defaultValue switch
|
||||||
|
{
|
||||||
|
null => NewComposer().Text(" "),
|
||||||
|
"" => NewComposer().Text(" "),
|
||||||
|
Array { Length: 0 } => NewComposer().Text(" "),
|
||||||
|
Array array => NewComposer().Join(", ", array.Cast<object>().Select(o => NewComposer().Style(helpStyles?.Options?.DefaultValue ?? Style.Plain, o.ToString() ?? string.Empty))),
|
||||||
|
_ => NewComposer().Style(helpStyles?.Options?.DefaultValue ?? Style.Plain, defaultValue?.ToString() ?? string.Empty),
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
@ -9,4 +9,9 @@ public interface ICommandModel : ICommandContainer
|
|||||||
/// Gets the name of the application.
|
/// Gets the name of the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string ApplicationName { get; }
|
string ApplicationName { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the version of the application.
|
||||||
|
/// </summary>
|
||||||
|
string? ApplicationVersion { get; }
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,12 @@ internal sealed class CommandExecutor
|
|||||||
if (firstArgument.Equals("--version", StringComparison.OrdinalIgnoreCase) ||
|
if (firstArgument.Equals("--version", StringComparison.OrdinalIgnoreCase) ||
|
||||||
firstArgument.Equals("-v", StringComparison.OrdinalIgnoreCase))
|
firstArgument.Equals("-v", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var console = configuration.Settings.Console.GetConsole();
|
if (configuration.Settings.ApplicationVersion != null)
|
||||||
console.WriteLine(ResolveApplicationVersion(configuration));
|
{
|
||||||
return 0;
|
var console = configuration.Settings.Console.GetConsole();
|
||||||
|
console.MarkupLine(configuration.Settings.ApplicationVersion);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,13 +129,6 @@ internal sealed class CommandExecutor
|
|||||||
return parsedResult;
|
return parsedResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string ResolveApplicationVersion(IConfiguration configuration)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
configuration.Settings.ApplicationVersion ?? // potential override
|
|
||||||
VersionHelper.GetVersion(Assembly.GetEntryAssembly());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static async Task<int> Execute(
|
private static async Task<int> Execute(
|
||||||
CommandTree leaf,
|
CommandTree leaf,
|
||||||
CommandTree tree,
|
CommandTree tree,
|
||||||
|
@ -3,6 +3,7 @@ namespace Spectre.Console.Cli;
|
|||||||
internal sealed class CommandModel : ICommandContainer, ICommandModel
|
internal sealed class CommandModel : ICommandContainer, ICommandModel
|
||||||
{
|
{
|
||||||
public string? ApplicationName { get; }
|
public string? ApplicationName { get; }
|
||||||
|
public string? ApplicationVersion { get; }
|
||||||
public ParsingMode ParsingMode { get; }
|
public ParsingMode ParsingMode { get; }
|
||||||
public IList<CommandInfo> Commands { get; }
|
public IList<CommandInfo> Commands { get; }
|
||||||
public IList<string[]> Examples { get; }
|
public IList<string[]> Examples { get; }
|
||||||
@ -20,9 +21,10 @@ internal sealed class CommandModel : ICommandContainer, ICommandModel
|
|||||||
IEnumerable<string[]> examples)
|
IEnumerable<string[]> examples)
|
||||||
{
|
{
|
||||||
ApplicationName = settings.ApplicationName;
|
ApplicationName = settings.ApplicationName;
|
||||||
|
ApplicationVersion = settings.ApplicationVersion;
|
||||||
ParsingMode = settings.ParsingMode;
|
ParsingMode = settings.ParsingMode;
|
||||||
Commands = new List<CommandInfo>(commands ?? Array.Empty<CommandInfo>());
|
Commands = new List<CommandInfo>(commands);
|
||||||
Examples = new List<string[]>(examples ?? Array.Empty<string[]>());
|
Examples = new List<string[]>(examples);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
USAGE:
|
USAGE:
|
||||||
myapp <FOO> <BAR> <BAZ> <CORGI> [QUX] [OPTIONS]
|
myapp <FOO> <BAR> <BAZ> <CORGI> [QUX] [OPTIONS]
|
||||||
|
|
||||||
ARGUMENTS:
|
ARGUMENTS:
|
||||||
@ -9,5 +9,4 @@ ARGUMENTS:
|
|||||||
[QUX]
|
[QUX]
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
@ -1,15 +1,14 @@
|
|||||||
--------------------------------------
|
--------------------------------------
|
||||||
--- CUSTOM HELP PROVIDER ---
|
--- CUSTOM HELP PROVIDER ---
|
||||||
--------------------------------------
|
--------------------------------------
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
myapp [OPTIONS] <COMMAND>
|
myapp [OPTIONS] <COMMAND>
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
|
COMMANDS:
|
||||||
COMMANDS:
|
dog <AGE> The dog command
|
||||||
dog <AGE> The dog command
|
|
||||||
|
|
||||||
Version 1.0
|
Version 1.0
|
@ -1,4 +1,4 @@
|
|||||||
--------------------------------------
|
--------------------------------------
|
||||||
--- CUSTOM HELP PROVIDER ---
|
--- CUSTOM HELP PROVIDER ---
|
||||||
--------------------------------------
|
--------------------------------------
|
||||||
|
|
||||||
@ -6,8 +6,7 @@ USAGE:
|
|||||||
myapp [OPTIONS] <COMMAND>
|
myapp [OPTIONS] <COMMAND>
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
dog <AGE> The dog command
|
dog <AGE> The dog command
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
The lion command.
|
The lion command.
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
@ -10,8 +10,7 @@ ARGUMENTS:
|
|||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
DEFAULT
|
DEFAULT
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
-a, --alive Indicates whether or not the animal is alive
|
-a, --alive Indicates whether or not the animal is alive
|
||||||
-n, --name <VALUE>
|
-n, --name <VALUE>
|
||||||
--agility <VALUE> 10 The agility between 0 and 100
|
--agility <VALUE> 10 The agility between 0 and 100
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
The dog command.
|
The dog command.
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
@ -18,7 +18,6 @@ ARGUMENTS:
|
|||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
-a, --alive Indicates whether or not the animal is alive
|
-a, --alive Indicates whether or not the animal is alive
|
||||||
-n, --name <VALUE>
|
-n, --name <VALUE>
|
||||||
-g, --good-boy
|
-g, --good-boy
|
@ -1,4 +1,4 @@
|
|||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
The lion command.
|
The lion command.
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
@ -10,8 +10,7 @@ ARGUMENTS:
|
|||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
DEFAULT
|
DEFAULT
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
-a, --alive Indicates whether or not the animal is alive
|
-a, --alive Indicates whether or not the animal is alive
|
||||||
-n, --name <VALUE>
|
-n, --name <VALUE>
|
||||||
--agility <VALUE> 10 The agility between 0 and 100
|
--agility <VALUE> 10 The agility between 0 and 100
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
BESCHREIBUNG:
|
BESCHREIBUNG:
|
||||||
The lion command.
|
The lion command.
|
||||||
|
|
||||||
VERWENDUNG:
|
VERWENDUNG:
|
||||||
@ -14,7 +14,6 @@ ARGUMENTE:
|
|||||||
OPTIONEN:
|
OPTIONEN:
|
||||||
STANDARDWERT
|
STANDARDWERT
|
||||||
-h, --help Zeigt Hilfe an
|
-h, --help Zeigt Hilfe an
|
||||||
-v, --version Zeigt Versionsinformationen an
|
|
||||||
-a, --alive Indicates whether or not the animal is alive
|
-a, --alive Indicates whether or not the animal is alive
|
||||||
-n, --name <VALUE>
|
-n, --name <VALUE>
|
||||||
--agility <VALUE> 10 The agility between 0 and 100
|
--agility <VALUE> 10 The agility between 0 and 100
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
The lion command.
|
The lion command.
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
@ -13,8 +13,7 @@ ARGUMENTS:
|
|||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
DEFAULT
|
DEFAULT
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
-a, --alive Indicates whether or not the animal is alive
|
-a, --alive Indicates whether or not the animal is alive
|
||||||
-n, --name <VALUE>
|
-n, --name <VALUE>
|
||||||
--agility <VALUE> 10 The agility between 0 and 100
|
--agility <VALUE> 10 The agility between 0 and 100
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
The lion command.
|
The lion command.
|
||||||
|
|
||||||
UTILISATION:
|
UTILISATION:
|
||||||
@ -13,8 +13,7 @@ ARGUMENTS:
|
|||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
DÉFAUT
|
DÉFAUT
|
||||||
-h, --help Affiche l'aide
|
-h, --help Affiche l'aide
|
||||||
-v, --version Affiche la version
|
|
||||||
-a, --alive Indicates whether or not the animal is alive
|
-a, --alive Indicates whether or not the animal is alive
|
||||||
-n, --name <VALUE>
|
-n, --name <VALUE>
|
||||||
--agility <VALUE> 10 The agility between 0 and 100
|
--agility <VALUE> 10 The agility between 0 and 100
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
BESKRIVNING:
|
BESKRIVNING:
|
||||||
The lion command.
|
The lion command.
|
||||||
|
|
||||||
ANVÄNDING:
|
ANVÄNDING:
|
||||||
@ -14,7 +14,6 @@ ARGUMENT:
|
|||||||
VAL:
|
VAL:
|
||||||
STANDARD
|
STANDARD
|
||||||
-h, --help Skriver ut hjälpinformation
|
-h, --help Skriver ut hjälpinformation
|
||||||
-v, --version Skriver ut versionsnummer
|
|
||||||
-a, --alive Indicates whether or not the animal is alive
|
-a, --alive Indicates whether or not the animal is alive
|
||||||
-n, --name <VALUE>
|
-n, --name <VALUE>
|
||||||
--agility <VALUE> 10 The agility between 0 and 100
|
--agility <VALUE> 10 The agility between 0 and 100
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[bold]DESCRIPTION:[/]
|
[bold]DESCRIPTION:[/]
|
||||||
The lion command.
|
The lion command.
|
||||||
|
|
||||||
[bold]USAGE:[/]
|
[bold]USAGE:[/]
|
||||||
@ -14,7 +14,6 @@ The lion command.
|
|||||||
[]OPTIONS:[/]
|
[]OPTIONS:[/]
|
||||||
[]DEFAULT[/]
|
[]DEFAULT[/]
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
-a, --alive Indicates whether or not the animal is alive
|
-a, --alive Indicates whether or not the animal is alive
|
||||||
-n, --name []<VALUE>[/]
|
-n, --name []<VALUE>[/]
|
||||||
--agility []<VALUE>[/] []10[/] The agility between 0 and 100
|
--agility []<VALUE>[/] []10[/] The agility between 0 and 100
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[yellow]DESCRIPTION:[/]
|
[yellow]DESCRIPTION:[/]
|
||||||
The lion command.
|
The lion command.
|
||||||
|
|
||||||
[yellow]USAGE:[/]
|
[yellow]USAGE:[/]
|
||||||
@ -14,7 +14,6 @@ The lion command.
|
|||||||
[yellow]OPTIONS:[/]
|
[yellow]OPTIONS:[/]
|
||||||
[lime]DEFAULT[/]
|
[lime]DEFAULT[/]
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
-a, --alive Indicates whether or not the animal is alive
|
-a, --alive Indicates whether or not the animal is alive
|
||||||
-n, --name [silver]<VALUE>[/]
|
-n, --name [silver]<VALUE>[/]
|
||||||
--agility [silver]<VALUE>[/] [bold]10[/] The agility between 0 and 100
|
--agility [silver]<VALUE>[/] [bold]10[/] The agility between 0 and 100
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[]DESCRIPTION:[/]
|
[]DESCRIPTION:[/]
|
||||||
The lion command.
|
The lion command.
|
||||||
|
|
||||||
[]USAGE:[/]
|
[]USAGE:[/]
|
||||||
@ -14,7 +14,6 @@ The lion command.
|
|||||||
[]OPTIONS:[/]
|
[]OPTIONS:[/]
|
||||||
[]DEFAULT[/]
|
[]DEFAULT[/]
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
-a, --alive Indicates whether or not the animal is alive
|
-a, --alive Indicates whether or not the animal is alive
|
||||||
-n, --name []<VALUE>[/]
|
-n, --name []<VALUE>[/]
|
||||||
--agility []<VALUE>[/] []10[/] The agility between 0 and 100
|
--agility []<VALUE>[/] []10[/] The agility between 0 and 100
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
USAGE:
|
USAGE:
|
||||||
myapp [OPTIONS] <COMMAND>
|
myapp [OPTIONS] <COMMAND>
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
dog <AGE> The dog command.
|
dog <AGE> The dog command.
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
USAGE:
|
USAGE:
|
||||||
myapp <FOO> [OPTIONS]
|
myapp <FOO> [OPTIONS]
|
||||||
|
|
||||||
ARGUMENTS:
|
ARGUMENTS:
|
||||||
<FOO> Dummy argument FOO
|
<FOO> Dummy argument FOO
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
--baz Dummy option BAZ
|
||||||
--baz Dummy option BAZ
|
|
@ -1,9 +1,8 @@
|
|||||||
USAGE:
|
USAGE:
|
||||||
myapp [OPTIONS] <COMMAND>
|
myapp [OPTIONS] <COMMAND>
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
dog <AGE> The dog command
|
dog <AGE> The dog command
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
USAGE:
|
USAGE:
|
||||||
myapp [OPTIONS] <COMMAND>
|
myapp [OPTIONS] <COMMAND>
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
bar
|
bar
|
@ -0,0 +1,12 @@
|
|||||||
|
USAGE:
|
||||||
|
myapp <FOO> <BAR> <BAZ> <CORGI> [QUX] [OPTIONS]
|
||||||
|
|
||||||
|
ARGUMENTS:
|
||||||
|
<FOO>
|
||||||
|
<BAR>
|
||||||
|
<BAZ>
|
||||||
|
<CORGI>
|
||||||
|
[QUX]
|
||||||
|
|
||||||
|
OPTIONS:
|
||||||
|
-h, --help Prints help information
|
@ -1,9 +1,8 @@
|
|||||||
USAGE:
|
USAGE:
|
||||||
myapp [OPTIONS] <COMMAND>
|
myapp [OPTIONS] <COMMAND>
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
dog <AGE> The dog command
|
dog <AGE> The dog command
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
The horse command.
|
The horse command.
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
@ -10,7 +10,6 @@ ARGUMENTS:
|
|||||||
OPTIONS:
|
OPTIONS:
|
||||||
DEFAULT
|
DEFAULT
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
-a, --alive Indicates whether or not the animal is alive
|
-a, --alive Indicates whether or not the animal is alive
|
||||||
-n, --name <VALUE>
|
-n, --name <VALUE>
|
||||||
-d, --day <MON|TUE>
|
-d, --day <MON|TUE>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
USAGE:
|
USAGE:
|
||||||
myapp [OPTIONS] <COMMAND>
|
myapp [OPTIONS] <COMMAND>
|
||||||
|
|
||||||
EXAMPLES:
|
EXAMPLES:
|
||||||
@ -16,8 +16,7 @@ EXAMPLES:
|
|||||||
myapp horse --name Spirit
|
myapp horse --name Spirit
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
dog <AGE> The dog command
|
dog <AGE> The dog command
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
USAGE:
|
USAGE:
|
||||||
myapp [OPTIONS] <COMMAND>
|
myapp [OPTIONS] <COMMAND>
|
||||||
|
|
||||||
EXAMPLES:
|
EXAMPLES:
|
||||||
@ -9,8 +9,7 @@ EXAMPLES:
|
|||||||
myapp dog --name Daisy
|
myapp dog --name Daisy
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
dog <AGE> The dog command
|
dog <AGE> The dog command
|
||||||
|
@ -1,20 +1,19 @@
|
|||||||
USAGE:
|
USAGE:
|
||||||
myapp [OPTIONS] <COMMAND>
|
myapp [OPTIONS] <COMMAND>
|
||||||
|
|
||||||
EXAMPLES:
|
EXAMPLES:
|
||||||
myapp dog --name Rufus --age 12 --good-boy
|
myapp dog --name Rufus --age 12 --good-boy
|
||||||
myapp dog --name Luna
|
myapp dog --name Luna
|
||||||
myapp dog --name Charlie
|
myapp dog --name Charlie
|
||||||
myapp dog --name Bella
|
myapp dog --name Bella
|
||||||
myapp dog --name Daisy
|
myapp dog --name Daisy
|
||||||
myapp dog --name Milo
|
myapp dog --name Milo
|
||||||
myapp horse --name Brutus
|
myapp horse --name Brutus
|
||||||
myapp horse --name Sugar --IsAlive false
|
myapp horse --name Sugar --IsAlive false
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
|
COMMANDS:
|
||||||
COMMANDS:
|
dog <AGE> The dog command
|
||||||
dog <AGE> The dog command
|
|
||||||
horse The horse command
|
horse The horse command
|
@ -1,10 +1,9 @@
|
|||||||
USAGE:
|
USAGE:
|
||||||
myapp [OPTIONS] <COMMAND>
|
myapp [OPTIONS] <COMMAND>
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
|
COMMANDS:
|
||||||
COMMANDS:
|
dog <AGE> The dog command
|
||||||
dog <AGE> The dog command
|
|
||||||
horse The horse command
|
horse The horse command
|
@ -1,24 +1,23 @@
|
|||||||
USAGE:
|
USAGE:
|
||||||
myapp [OPTIONS] <COMMAND>
|
myapp [OPTIONS] <COMMAND>
|
||||||
|
|
||||||
EXAMPLES:
|
EXAMPLES:
|
||||||
myapp dog --name Rufus --age 12 --good-boy
|
myapp dog --name Rufus --age 12 --good-boy
|
||||||
myapp dog --name Luna
|
myapp dog --name Luna
|
||||||
myapp dog --name Charlie
|
myapp dog --name Charlie
|
||||||
myapp dog --name Bella
|
myapp dog --name Bella
|
||||||
myapp dog --name Daisy
|
myapp dog --name Daisy
|
||||||
myapp dog --name Milo
|
myapp dog --name Milo
|
||||||
myapp horse --name Brutus
|
myapp horse --name Brutus
|
||||||
myapp horse --name Sugar --IsAlive false
|
myapp horse --name Sugar --IsAlive false
|
||||||
myapp horse --name Cash
|
myapp horse --name Cash
|
||||||
myapp horse --name Dakota
|
myapp horse --name Dakota
|
||||||
myapp horse --name Cisco
|
myapp horse --name Cisco
|
||||||
myapp horse --name Spirit
|
myapp horse --name Spirit
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
|
COMMANDS:
|
||||||
COMMANDS:
|
dog <AGE> The dog command
|
||||||
dog <AGE> The dog command
|
|
||||||
horse The horse command
|
horse The horse command
|
@ -1,4 +1,4 @@
|
|||||||
USAGE:
|
USAGE:
|
||||||
myapp [OPTIONS] <COMMAND>
|
myapp [OPTIONS] <COMMAND>
|
||||||
|
|
||||||
EXAMPLES:
|
EXAMPLES:
|
||||||
@ -9,8 +9,7 @@ EXAMPLES:
|
|||||||
myapp animal dog --name Daisy
|
myapp animal dog --name Daisy
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
animal The animal command
|
animal The animal command
|
@ -12,8 +12,7 @@ EXAMPLES:
|
|||||||
myapp animal horse --name Sugar --IsAlive false
|
myapp animal horse --name Sugar --IsAlive false
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
animal The animal command
|
animal The animal command
|
@ -1,9 +1,8 @@
|
|||||||
USAGE:
|
USAGE:
|
||||||
myapp [OPTIONS] <COMMAND>
|
myapp [OPTIONS] <COMMAND>
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
animal The animal command
|
animal The animal command
|
@ -16,8 +16,7 @@ EXAMPLES:
|
|||||||
myapp animal horse --name Spirit
|
myapp animal horse --name Spirit
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h, --help Prints help information
|
-h, --help Prints help information
|
||||||
-v, --version Prints version information
|
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
animal The animal command
|
animal The animal command
|
@ -0,0 +1,13 @@
|
|||||||
|
USAGE:
|
||||||
|
myapp <FOO> <BAR> <BAZ> <CORGI> [QUX] [OPTIONS]
|
||||||
|
|
||||||
|
ARGUMENTS:
|
||||||
|
<FOO>
|
||||||
|
<BAR>
|
||||||
|
<BAZ>
|
||||||
|
<CORGI>
|
||||||
|
[QUX]
|
||||||
|
|
||||||
|
OPTIONS:
|
||||||
|
-h, --help Prints help information
|
||||||
|
-v, --version Prints version information
|
@ -950,6 +950,45 @@ public sealed partial class CommandAppTests
|
|||||||
return Verifier.Verify(result.Output);
|
return Verifier.Verify(result.Output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Expectation("NoVersion")]
|
||||||
|
public Task Should_Not_Include_Application_Version_If_Not_Set()
|
||||||
|
{
|
||||||
|
// Given
|
||||||
|
var fixture = new CommandAppTester();
|
||||||
|
fixture.SetDefaultCommand<GenericCommand<ArgumentOrderSettings>>();
|
||||||
|
fixture.Configure(config =>
|
||||||
|
{
|
||||||
|
config.SetApplicationName("myapp");
|
||||||
|
});
|
||||||
|
|
||||||
|
// When
|
||||||
|
var result = fixture.Run("--help");
|
||||||
|
|
||||||
|
// Then
|
||||||
|
return Verifier.Verify(result.Output);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Expectation("Version")]
|
||||||
|
public Task Should_Include_Application_Version_If_Set()
|
||||||
|
{
|
||||||
|
// Given
|
||||||
|
var fixture = new CommandAppTester();
|
||||||
|
fixture.SetDefaultCommand<GenericCommand<ArgumentOrderSettings>>();
|
||||||
|
fixture.Configure(config =>
|
||||||
|
{
|
||||||
|
config.SetApplicationName("myapp");
|
||||||
|
config.SetApplicationVersion("0.49.1");
|
||||||
|
});
|
||||||
|
|
||||||
|
// When
|
||||||
|
var result = fixture.Run("--help");
|
||||||
|
|
||||||
|
// Then
|
||||||
|
return Verifier.Verify(result.Output);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[Expectation("Hidden_Command_Options")]
|
[Expectation("Hidden_Command_Options")]
|
||||||
public Task Should_Not_Show_Hidden_Command_Options()
|
public Task Should_Not_Show_Hidden_Command_Options()
|
||||||
|
@ -34,6 +34,24 @@ public sealed partial class CommandAppTests
|
|||||||
result.Output.ShouldBe("1.0");
|
result.Output.ShouldBe("1.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Should_Not_Display_Version_If_Not_Specified()
|
||||||
|
{
|
||||||
|
// Given
|
||||||
|
var fixture = new CommandAppTester();
|
||||||
|
fixture.Configure(configurator =>
|
||||||
|
{
|
||||||
|
configurator.AddCommand<EmptyCommand>("empty");
|
||||||
|
});
|
||||||
|
|
||||||
|
// When
|
||||||
|
var result = fixture.Run("--version");
|
||||||
|
|
||||||
|
// Then
|
||||||
|
result.ExitCode.ShouldNotBe(0);
|
||||||
|
result.Output.ShouldStartWith("Error: Unexpected option 'version'");
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Should_Execute_Command_Not_Output_Application_Version_To_The_Console()
|
public void Should_Execute_Command_Not_Output_Application_Version_To_The_Console()
|
||||||
{
|
{
|
||||||
@ -42,7 +60,6 @@ public sealed partial class CommandAppTests
|
|||||||
fixture.Configure(configurator =>
|
fixture.Configure(configurator =>
|
||||||
{
|
{
|
||||||
configurator.SetApplicationVersion("1.0");
|
configurator.SetApplicationVersion("1.0");
|
||||||
|
|
||||||
configurator.AddCommand<EmptyCommand>("empty");
|
configurator.AddCommand<EmptyCommand>("empty");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -81,7 +98,6 @@ public sealed partial class CommandAppTests
|
|||||||
fixture.Configure(configurator =>
|
fixture.Configure(configurator =>
|
||||||
{
|
{
|
||||||
configurator.SetApplicationVersion("1.0");
|
configurator.SetApplicationVersion("1.0");
|
||||||
|
|
||||||
configurator.AddBranch<EmptyCommandSettings>("branch", branch =>
|
configurator.AddBranch<EmptyCommandSettings>("branch", branch =>
|
||||||
{
|
{
|
||||||
branch.SetDefaultCommand<EmptyCommand>();
|
branch.SetDefaultCommand<EmptyCommand>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user