コード例 #1
0
        private void PrintCommand(int maxWidth, CommandAttribute commandAttribute)
        {
            // Write out the command name left justified with the max command's width's padding
            Console.Write(" {0, -" + maxWidth + "}   ", GetCommandText(commandAttribute));
            // Starting index of the description
            int descriptionPadding = maxWidth + 4;

            Console.PrintJustified(descriptionPadding, commandAttribute.GetDescription());
        }
コード例 #2
0
 public void GetDescription_ReturnsResourceIfTypeSet()
 {
     // Arrange
     CommandAttribute cmd = new CommandAttribute(typeof(MockResourceType), "MockCommand", "ResourceName") { Description = "Not a string from a resouce." };
     // Act
     var actual = cmd.GetDescription();
     // Assert
     Assert.AreEqual("This is a Resource String.", actual);
 }
コード例 #3
0
 public void GetDescription_ReturnsDescriptionIfTypeNotSet()
 {
     // Arrange
     CommandAttribute cmd = new CommandAttribute("MockCommand", "ResourceName");
     // Act
     var actual = cmd.GetDescription();
     // Assert
     Assert.AreEqual("ResourceName", actual);
 }
コード例 #4
0
        public void GetDescription_ReturnsDescriptionIfTypeNotSet()
        {
            // Arrange
            CommandAttribute cmd = new CommandAttribute("MockCommand", "ResourceName");
            // Act
            var actual = cmd.GetDescription();

            // Assert
            Assert.AreEqual("ResourceName", actual);
        }
コード例 #5
0
        public void GetDescription_ReturnsResourceIfTypeSet()
        {
            // Arrange
            CommandAttribute cmd = new CommandAttribute(typeof(MockResourceType), "MockCommand", "ResourceName")
            {
                Description = "Not a string from a resouce."
            };
            // Act
            var actual = cmd.GetDescription();

            // Assert
            Assert.AreEqual("This is a Resource String.", actual);
        }
コード例 #6
0
        public void ViewHelpForCommand(string commandName)
        {
            ICommand         command   = _commandManager.GetCommand(commandName);
            CommandAttribute attribute = command.CommandAttribute;

            Console.WriteLine("usage: {0} {1} {2}", _commandExe, attribute.CommandName, attribute.GetUsageSummary());
            Console.WriteLine();

            if (!String.IsNullOrEmpty(attribute.AltName))
            {
                Console.WriteLine("alias: {0}", attribute.AltName);
                Console.WriteLine();
            }

            Console.WriteLine(attribute.GetDescription());
            Console.WriteLine();

            if (attribute.GetUsageDescription() != null)
            {
                int padding = 5;
                Console.PrintJustified(padding, attribute.GetUsageDescription());
                Console.WriteLine();
            }

            var options = _commandManager.GetCommandOptions(command);

            if (options.Count > 0)
            {
                Console.WriteLine("options:");
                Console.WriteLine();

                // Get the max option width. +2 for showing + against multivalued properties
                int maxOptionWidth = options.Max(o => o.Value.Name.Length) + 2;
                // Get the max altname option width
                int maxAltOptionWidth = options.Max(o => (o.Key.AltName ?? String.Empty).Length);

                foreach (var o in options)
                {
                    Console.Write(" {0, -" + (maxOptionWidth + 2) + "}", o.Value.Name +
                                  (CommandLineUtility.IsMultiValuedProperty(o.Value) ? " +" : String.Empty));
                    Console.Write(" {0, -" + (maxAltOptionWidth + 4) + "}", GetAltText(o.Key.AltName));

                    Console.PrintJustified((10 + maxAltOptionWidth + maxOptionWidth), o.Key.GetDescription());
                }
                Console.WriteLine();
            }
        }
コード例 #7
0
ファイル: HelpCommand.cs プロジェクト: jacksonh/nuget
 private void PrintCommand(int maxWidth, CommandAttribute commandAttribute)
 {
     // Write out the command name left justified with the max command's width's padding
     Console.Write(" {0, -" + maxWidth + "}   ", GetCommandText(commandAttribute));
     // Starting index of the description
     int descriptionPadding = maxWidth + 4;
     Console.PrintJustified(descriptionPadding, commandAttribute.GetDescription());
 }