mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-16 12:13:22 +08:00
Display the application version (if set) when a version flag is the first argument, even if a default command has been set.
This commit is contained in:
parent
17c7a4f7d6
commit
dfdd129dd0
@ -29,24 +29,20 @@ internal sealed class CommandExecutor
|
|||||||
_registrar.RegisterInstance(typeof(CommandModel), model);
|
_registrar.RegisterInstance(typeof(CommandModel), model);
|
||||||
_registrar.RegisterDependencies(model);
|
_registrar.RegisterDependencies(model);
|
||||||
|
|
||||||
// No default command?
|
// Got at least one argument?
|
||||||
if (model.DefaultCommand == null)
|
var firstArgument = arguments.FirstOrDefault();
|
||||||
|
if (firstArgument != null)
|
||||||
{
|
{
|
||||||
// Got at least one argument?
|
// Asking for version? Kind of a hack, but it's alright.
|
||||||
var firstArgument = arguments.FirstOrDefault();
|
// We should probably make this a bit better in the future.
|
||||||
if (firstArgument != null)
|
if (firstArgument.Equals("--version", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
firstArgument.Equals("-v", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
// Asking for version? Kind of a hack, but it's alright.
|
if (configuration.Settings.ApplicationVersion != null)
|
||||||
// We should probably make this a bit better in the future.
|
|
||||||
if (firstArgument.Equals("--version", StringComparison.OrdinalIgnoreCase) ||
|
|
||||||
firstArgument.Equals("-v", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
{
|
||||||
if (configuration.Settings.ApplicationVersion != null)
|
var console = configuration.Settings.Console.GetConsole();
|
||||||
{
|
console.MarkupLine(configuration.Settings.ApplicationVersion);
|
||||||
var console = configuration.Settings.Console.GetConsole();
|
return 0;
|
||||||
console.MarkupLine(configuration.Settings.ApplicationVersion);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user