NuDeploy.CommandLine.Commands.HelpProvider.ShowHelpOverview C# (CSharp) Method

ShowHelpOverview() public method

public ShowHelpOverview ( IEnumerable commands ) : void
commands IEnumerable
return void
        public void ShowHelpOverview(IEnumerable<ICommand> commands)
        {
            if (commands == null)
            {
                throw new ArgumentNullException("commands");
            }

            // version
            this.userInterface.WriteLine(string.Format("{0} ({1})", this.applicationInformation.ApplicationName, this.applicationInformation.ApplicationVersion));

            this.userInterface.WriteLine(string.Empty);

            // usage
            string usageLabel = Resources.HelpCommand.UsageLabel + ":" + Environment.NewLine;
            this.userInterface.WriteLine(usageLabel);

            string usageText = string.Format(Resources.HelpCommand.UsagePattern, this.applicationInformation.NameOfExecutable);
            this.userInterface.ShowIndented(usageText, 4);

            this.userInterface.WriteLine(string.Empty);

            // help
            string helpLabel = Resources.HelpCommand.HelpLabel + ":" + Environment.NewLine;
            this.userInterface.WriteLine(helpLabel);

            string helpText = string.Format(Resources.HelpCommand.HelpPattern, this.applicationInformation.NameOfExecutable);
            this.userInterface.ShowIndented(helpText, 4);

            this.userInterface.WriteLine(string.Empty);

            // available commands
            string availableCommandsLabel = Resources.HelpCommand.AvailableCommandsLabel + ":";
            this.userInterface.WriteLine(availableCommandsLabel);
            this.userInterface.WriteLine(string.Empty);

            // display command name and description
            this.userInterface.ShowKeyValueStore(
                commands.ToDictionary(g => g.Attributes.CommandName, v => v.Attributes.Description),
                distanceBetweenColumns: 4,
                indentation: 2);

            this.userInterface.WriteLine(string.Empty);
        }

Usage Example

        public void ShowHelpOverview_ApplicationName_IsWrittenToTheUserInterface()
        {
            // Arrange
            var commands = new List<ICommand>();

            var applicationInformation = new ApplicationInformation { ApplicationName = "App Name" };

            var helpProvider = new HelpProvider(applicationInformation, this.loggingUserInterface.UserInterface);

            // Act
            helpProvider.ShowHelpOverview(commands);

            // Assert
            Assert.IsTrue(this.loggingUserInterface.UserInterfaceOutput.Contains(applicationInformation.ApplicationName));
        }
All Usage Examples Of NuDeploy.CommandLine.Commands.HelpProvider::ShowHelpOverview