/// <summary>
        /// Writes the help content of the <see cref="Command"/> subcommands, if any,
        /// for the supplied <see cref="command"/>
        /// </summary>
        /// <param name="command"></param>
        protected virtual void AddSubcommands(ICommand command)
        {
            var subcommands = command
                              .Children
                              .OfType <ICommand>()
                              .Where(ShouldShowHelp)
                              .ToArray();

            HelpSection.Write(this, Commands.Title, subcommands, GetOptionHelpItems);
        }
        /// <summary>
        /// Writes the <see cref="Option"/> help content, if any,
        /// for the supplied <see cref="command"/>
        /// </summary>
        /// <param name="command"></param>
        protected virtual void AddOptions(ICommand command)
        {
            var options = command
                          .Children
                          .OfType <IOption>()
                          .Where(ShouldShowHelp)
                          .ToArray();

            HelpSection.Write(this, Options.Title, options, GetOptionHelpItems);
        }
Exemple #3
0
        /// <summary>
        /// Writes a summary, if configured, for the supplied <see cref="command"/>
        /// </summary>
        /// <param name="command"></param>
        protected virtual void AddSynopsis(ICommand command)
        {
            if (!ShouldShowHelp(command))
            {
                return;
            }

            var title = $"{command.Name}:";

            HelpSection.Write(this, title, command.Description);
        }
Exemple #4
0
        /// <summary>
        /// Writes the arguments, if any, for the supplied <see cref="command"/>
        /// </summary>
        /// <param name="command"></param>
        protected virtual void AddArguments(ICommand command)
        {
            var commands = new List <ICommand>();

            if (command is Command cmd &&
                cmd.Parents.FirstOrDefault() is ICommand parent &&
                ShouldDisplayArgumentHelp(parent))
            {
                commands.Add(parent);
            }

            if (ShouldDisplayArgumentHelp(command))
            {
                commands.Add(command);
            }

            HelpSection.Write(this, Arguments.Title, commands, GetArgumentHelpItems);
        }