Skip to content

Commit 9240863

Browse files
baronfeldsplaisted
authored andcommitted
Minor help tweaks to allow --help on even hidden commands to output something.
This won't allow those commands to show up in subcommand-help of their parents, however.
1 parent 1a444fc commit 9240863

File tree

2 files changed

+28
-32
lines changed

2 files changed

+28
-32
lines changed

src/Cli/Microsoft.TemplateEngine.Cli/Help/HelpBuilder.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ public virtual void Write(HelpContext context)
4343
throw new ArgumentNullException(nameof(context));
4444
}
4545

46-
if (context.Command.Hidden)
47-
{
48-
return;
49-
}
50-
5146
foreach (var writeSection in GetLayout(context))
5247
{
5348
if (writeSection(context))

src/Cli/dotnet/Parser.cs

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -307,17 +307,14 @@ public override void Write(HelpContext context)
307307
{
308308
var command = context.Command;
309309
var helpArgs = new string[] { "--help" };
310+
311+
// custom help overrides
310312
if (command.Equals(RootCommand))
311313
{
312314
Console.Out.WriteLine(CliUsage.HelpText);
313315
return;
314316
}
315317

316-
foreach (var option in command.Options)
317-
{
318-
option.EnsureHelpName();
319-
}
320-
321318
if (command.Equals(NuGetCommandParser.GetCommand()) || command.Parents.Any(parent => parent == NuGetCommandParser.GetCommand()))
322319
{
323320
NuGetCommand.Run(context.ParseResult);
@@ -357,34 +354,38 @@ public override void Write(HelpContext context)
357354
{
358355
new FsiForwardingApp(helpArgs).Execute();
359356
}
360-
else
357+
358+
// argument/option cleanups specific to help
359+
foreach (var option in command.Options)
361360
{
362-
if (command.Name.Equals(ListReferenceCommandParser.GetCommand().Name))
363-
{
364-
Command listCommand = command.Parents.Single() as Command;
361+
option.EnsureHelpName();
362+
}
365363

366-
for (int i = 0; i < listCommand.Arguments.Count; i++)
364+
if (command.Name.Equals(ListReferenceCommandParser.GetCommand().Name))
365+
{
366+
Command listCommand = command.Parents.Single() as Command;
367+
368+
for (int i = 0; i < listCommand.Arguments.Count; i++)
369+
{
370+
if (listCommand.Arguments[i].Name == CliStrings.SolutionOrProjectArgumentName)
367371
{
368-
if (listCommand.Arguments[i].Name == CliStrings.SolutionOrProjectArgumentName)
369-
{
370-
// Name is immutable now, so we create a new Argument with the right name..
371-
listCommand.Arguments[i] = ListCommandParser.CreateSlnOrProjectArgument(CliStrings.ProjectArgumentName, CliStrings.ProjectArgumentDescription);
372-
}
372+
// Name is immutable now, so we create a new Argument with the right name..
373+
listCommand.Arguments[i] = ListCommandParser.CreateSlnOrProjectArgument(CliStrings.ProjectArgumentName, CliStrings.ProjectArgumentDescription);
373374
}
374375
}
375-
else if (command.Name.Equals(AddPackageCommandParser.GetCommand().Name) || command.Name.Equals(AddCommandParser.GetCommand().Name))
376-
{
377-
// Don't show package completions in help
378-
PackageAddCommandParser.CmdPackageArgument.CompletionSources.Clear();
379-
}
380-
else if (command.Name.Equals(WorkloadSearchCommandParser.GetCommand().Name))
381-
{
382-
// Set shorter description for displaying parent command help.
383-
WorkloadSearchVersionsCommandParser.GetCommand().Description = CliStrings.ShortWorkloadSearchVersionDescription;
384-
}
385-
386-
base.Write(context);
387376
}
377+
else if (command.Name.Equals(AddPackageCommandParser.GetCommand().Name) || command.Name.Equals(AddCommandParser.GetCommand().Name))
378+
{
379+
// Don't show package completions in help
380+
PackageAddCommandParser.CmdPackageArgument.CompletionSources.Clear();
381+
}
382+
else if (command.Name.Equals(WorkloadSearchCommandParser.GetCommand().Name))
383+
{
384+
// Set shorter description for displaying parent command help.
385+
WorkloadSearchVersionsCommandParser.GetCommand().Description = CliStrings.ShortWorkloadSearchVersionDescription;
386+
}
387+
388+
base.Write(context);
388389
}
389390
}
390391
}

0 commit comments

Comments
 (0)