mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-07-01 10:28:16 +08:00
Show help for default command (#953)
Shows help if the default command was called without any arguments but has required arguments. This way it does not hinder execution of a default command without any required arguments. When called without args: - Default command with required params -> Show help - Default command with required params and additional commands -> Show help including additional commands - Default command without required params -> Execute command
This commit is contained in:
@ -66,6 +66,14 @@ internal sealed class CommandExecutor
|
||||
return leaf.ShowHelp ? 0 : 1;
|
||||
}
|
||||
|
||||
// Is this the default and is it called without arguments when there are required arguments?
|
||||
if (leaf.Command.IsDefaultCommand && args.Count() == 0 && leaf.Command.Parameters.Any(p => p.Required))
|
||||
{
|
||||
// Display help for default command.
|
||||
configuration.Settings.Console.SafeRender(HelpWriter.WriteCommand(model, leaf.Command));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Register the arguments with the container.
|
||||
_registrar.RegisterInstance(typeof(IRemainingArguments), parsedResult.Remaining);
|
||||
|
||||
|
Reference in New Issue
Block a user