Skip to content

Commit

Permalink
Merge pull request dotnet#1476 from dotnet/master
Browse files Browse the repository at this point in the history
Merge master into release/2.1
  • Loading branch information
seancpeters authored Mar 16, 2018
2 parents 80dbaba + ac30235 commit d64935a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ namespace Microsoft.TemplateEngine.Cli.HelpAndUsage
{
internal static class HelpForTemplateResolution
{
public static CreationResultStatus CoordinateHelpAndUsageDisplay(TemplateListResolutionResult templateResolutionResult, IEngineEnvironmentSettings environmentSettings, INewCommandInput commandInput, IHostSpecificDataLoader hostDataLoader, ITelemetryLogger telemeteryLogger, TemplateCreator templateCreator, string defaultLanguage)
public static CreationResultStatus CoordinateHelpAndUsageDisplay(TemplateListResolutionResult templateResolutionResult, IEngineEnvironmentSettings environmentSettings, INewCommandInput commandInput, IHostSpecificDataLoader hostDataLoader, ITelemetryLogger telemetryLogger, TemplateCreator templateCreator, string defaultLanguage)
{
ShowUsageHelp(commandInput, telemetryLogger);

// this is just checking if there is an unambiguous group.
// the called methods decide whether to get the default language filtered lists, based on what they're doing.
//
Expand All @@ -29,7 +31,7 @@ public static CreationResultStatus CoordinateHelpAndUsageDisplay(TemplateListRes
}
else
{
return DisplayHelpForAmbiguousTemplateGroup(templateResolutionResult, environmentSettings, commandInput, hostDataLoader, telemeteryLogger, defaultLanguage);
return DisplayHelpForAmbiguousTemplateGroup(templateResolutionResult, environmentSettings, commandInput, hostDataLoader, telemetryLogger, defaultLanguage);
}
}

Expand Down Expand Up @@ -73,8 +75,6 @@ private static CreationResultStatus DisplayHelpForUnambiguousTemplateGroup(Templ

private static CreationResultStatus TemplateDetailedHelpForSingularTemplateGroup(IReadOnlyList<ITemplateMatchInfo> unambiguousTemplateGroup, IEngineEnvironmentSettings environmentSettings, INewCommandInput commandInput, IHostSpecificDataLoader hostDataLoader, TemplateCreator templateCreator)
{
ShowUsageHelp(commandInput);

// (scp 2017-09-06): parse errors probably can't happen in this context.
foreach (string parseErrorMessage in unambiguousTemplateGroup.Where(x => x.HasParseError()).Select(x => x.GetParseError()).ToList())
{
Expand Down Expand Up @@ -130,13 +130,6 @@ private static CreationResultStatus DisplayHelpForAmbiguousTemplateGroup(Templat
DisplayParametersInvalidForSomeTemplates(invalidForSomeTemplates, LocalizableStrings.PartialTemplateMatchSwitchesNotValidForAllMatches);
}

if (commandInput.IsHelpFlagSpecified)
{
// usage help should show first (if it's being shown at all).
telemetryLogger.TrackEvent(commandInput.CommandName + "-Help");
ShowUsageHelp(commandInput);
}

ShowContextAndTemplateNameMismatchHelp(templateResolutionResult, commandInput.TemplateName, commandInput.TypeFilter);
DisplayTemplateList(templatesForDisplay, environmentSettings, commandInput.Language, defaultLanguage);

Expand Down Expand Up @@ -434,8 +427,13 @@ public static void GetParametersInvalidForTemplatesInList(IReadOnlyList<ITemplat
}
}

public static void ShowUsageHelp(INewCommandInput commandInput)
public static void ShowUsageHelp(INewCommandInput commandInput, ITelemetryLogger telemetryLogger)
{
if (commandInput.IsHelpFlagSpecified)
{
telemetryLogger.TrackEvent(commandInput.CommandName + "-Help");
}

Reporter.Output.WriteLine(commandInput.HelpText);
Reporter.Output.WriteLine();
}
Expand All @@ -448,8 +446,8 @@ public static CreationResultStatus HandleParseError(INewCommandInput commandInpu
// TODO: get a meaningful error message from the parser
if (commandInput.IsHelpFlagSpecified)
{
telemetryLogger.TrackEvent(commandInput.CommandName + "-Help");
ShowUsageHelp(commandInput);
// this code path doesn't go through the full help & usage stack, so needs it's own call to ShowUsageHelp().
ShowUsageHelp(commandInput, telemetryLogger);
}
else
{
Expand Down
5 changes: 2 additions & 3 deletions src/Microsoft.TemplateEngine.Cli/New3Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ private CreationResultStatus EnterMaintenanceFlow()
HelpForTemplateResolution.DisplayInvalidParameters(invalidParams);
if (_commandInput.IsHelpFlagSpecified)
{
_telemetryLogger.TrackEvent(CommandName + "-Help");
HelpForTemplateResolution.ShowUsageHelp(_commandInput);
// this code path doesn't go through the full help & usage stack, so needs it's own call to ShowUsageHelp().
HelpForTemplateResolution.ShowUsageHelp(_commandInput, _telemetryLogger);
}
else
{
Expand Down Expand Up @@ -414,7 +414,6 @@ private CreationResultStatus EnterMaintenanceFlow()
}

//No other cases specified, we've fallen through to "Usage help + List"
HelpForTemplateResolution.ShowUsageHelp(_commandInput);
TemplateListResolutionResult templateResolutionResult = QueryForTemplateMatches();
HelpForTemplateResolution.CoordinateHelpAndUsageDisplay(templateResolutionResult, EnvironmentSettings, _commandInput, _hostDataLoader, _telemetryLogger, _templateCreator, _defaultLanguage);

Expand Down

0 comments on commit d64935a

Please sign in to comment.