in Source/NuGetGallery.Operations/Commands/HelpCommand.cs [113:167]
public void ViewHelpForCommand(string commandName)
{
ICommand command = _commandManager.GetCommand(commandName);
CommandAttribute attribute = command.CommandAttribute;
Console.WriteLine("usage: {0} {1} {2}", _commandExe, attribute.CommandName, attribute.UsageSummary);
Console.WriteLine();
if (!String.IsNullOrEmpty(attribute.AltName))
{
Console.WriteLine("alias: {0}", attribute.AltName);
Console.WriteLine();
}
Console.WriteLine(attribute.Description);
Console.WriteLine();
if (attribute.UsageDescription != null)
{
const int padding = 5;
PrintJustified(padding, attribute.UsageDescription);
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 +
(TypeHelper.IsMultiValuedProperty(o.Value) ? " +" : String.Empty));
Console.Write(" {0, -" + (maxAltOptionWidth + 4) + "}", GetAltText(o.Key.AltName));
PrintJustified((10 + maxAltOptionWidth + maxOptionWidth), o.Key.Description);
}
if (_helpUrl != null)
{
Console.WriteLine();
Console.WriteLine("For more information, visit {0}", _helpUrl);
}
Console.WriteLine();
}
}