public void PostFilter(ICommandLineFilterContext context) { var verb = context.Verb; if (string.IsNullOrWhiteSpace(verb)) { // 启用标准命令行处理(额外:这是最后机会,空谓词时也提示帮助)。 Run(context, true); } else { // 无论是否启用了 Help 均提示谓词找不到。 context.SuppressFurtherHandlers(0); PrintUnknownVerbHelpText(verb); } }
private void Run(ICommandLineFilterContext contextInterface, bool helpEmptyVerb) { var context = (CommandLineFilterContext)contextInterface; var types = context.EnumerateRelatedTypes().ToList(); _localizableStrings ??= new LocalizableStrings(); if (Help) { context.SuppressFurtherHandlers(0); if (context.Verb is string verb && !string.IsNullOrWhiteSpace(verb)) { PrintVerbHelpText(context.GetVerbType() !, verb); } else { PrintDetailHelpText(types); } }
public void Filter(ICommandLineFilterContext context) { // 启用标准命令行处理(额外:空谓词时不处理,留后续处理)。 Run(context, false); }