private static void WriteSynopsis( Command command, StringBuilder helpView) { helpView.Append(Synopsis.Title); foreach (var subcommand in command .RecurseWhileNotNull(c => c.Parent as Command) .Reverse()) { helpView.Append($" {subcommand.Name}"); var argsName = subcommand.ArgumentsRule.Name; if (subcommand != command && !string.IsNullOrWhiteSpace(argsName)) { helpView.Append($" <{argsName}>"); } } if (command.DefinedOptions .Any(o => !o.IsCommand && !o.IsHidden())) { helpView.Append(Synopsis.Options); } var argumentsName = command.ArgumentsRule.Name; if (!string.IsNullOrWhiteSpace(argumentsName)) { helpView.Append($" <{argumentsName}>"); } if (command.DefinedOptions.OfType <Command>().Any()) { helpView.Append(Synopsis.Command); } if (!command.TreatUnmatchedTokensAsErrors) { helpView.Append(Synopsis.AdditionalArguments); } helpView.AppendLine(); }
public static string FullyQualifiedName(this Command command) => string.Join(" ", command.RecurseWhileNotNull(c => c.Parent as Command) .Reverse());