Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We don't need this 🙃 #35594

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected IReadOnlyDictionary<FilterOptionDefinition, CliOption> SetupFilterOpti
foreach (FilterOptionDefinition filterDef in filtersToSetup)
{
CliOption newOption = GetFilterOption(filterDef);
this.Options.Add(newOption);
Options.Add(newOption);
options[filterDef] = newOption;
}
return options;
Expand All @@ -141,8 +141,8 @@ protected IReadOnlyDictionary<FilterOptionDefinition, CliOption> SetupFilterOpti
/// </summary>
protected void SetupTabularOutputOptions(ITabularOutputCommand command)
{
this.Options.Add(command.ColumnsAllOption);
this.Options.Add(command.ColumnsOption);
Options.Add(command.ColumnsAllOption);
Options.Add(command.ColumnsOption);
}

private static async Task HandleGlobalOptionsAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,33 +135,33 @@ private static void ValidateArgumentUsage(CommandResult commandResult, params Cl

private void BuildLegacySymbols(Func<ParseResult, ITemplateEngineHost> hostBuilder)
{
this.Arguments.Add(ShortNameArgument);
this.Arguments.Add(RemainingArguments);
Arguments.Add(ShortNameArgument);
Arguments.Add(RemainingArguments);

//legacy options
Dictionary<FilterOptionDefinition, CliOption> options = new();
foreach (var filterDef in LegacyFilterDefinitions)
{
options[filterDef] = filterDef.OptionFactory().AsHidden();
this.Options.Add(options[filterDef]);
Options.Add(options[filterDef]);
}
LegacyFilters = options;

this.Options.Add(InteractiveOption);
this.Options.Add(AddSourceOption);
this.Options.Add(ColumnsAllOption);
this.Options.Add(ColumnsOption);

this.TreatUnmatchedTokensAsErrors = true;

this.Add(new LegacyInstallCommand(this, hostBuilder));
this.Add(new LegacyUninstallCommand(this, hostBuilder));
this.Add(new LegacyUpdateCheckCommand(this, hostBuilder));
this.Add(new LegacyUpdateApplyCommand(this, hostBuilder));
this.Add(new LegacySearchCommand(this, hostBuilder));
this.Add(new LegacyListCommand(this, hostBuilder));
this.Add(new LegacyAliasAddCommand(hostBuilder));
this.Add(new LegacyAliasShowCommand(hostBuilder));
Options.Add(InteractiveOption);
Options.Add(AddSourceOption);
Options.Add(ColumnsAllOption);
Options.Add(ColumnsOption);

TreatUnmatchedTokensAsErrors = true;

Add(new LegacyInstallCommand(this, hostBuilder));
Add(new LegacyUninstallCommand(this, hostBuilder));
Add(new LegacyUpdateCheckCommand(this, hostBuilder));
Add(new LegacyUpdateApplyCommand(this, hostBuilder));
Add(new LegacySearchCommand(this, hostBuilder));
Add(new LegacyListCommand(this, hostBuilder));
Add(new LegacyAliasAddCommand(hostBuilder));
Add(new LegacyAliasShowCommand(hostBuilder));
}
}
}
Expand Down
46 changes: 23 additions & 23 deletions src/Cli/Microsoft.TemplateEngine.Cli/Commands/NewCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,33 @@ internal NewCommand(
Func<ParseResult, ITemplateEngineHost> hostBuilder)
: base(hostBuilder, commandName, SymbolStrings.Command_New_Description)
{
this.TreatUnmatchedTokensAsErrors = true;
TreatUnmatchedTokensAsErrors = true;

//it is important that legacy commands are built before non-legacy, as non legacy commands are building validators that rely on legacy stuff
BuildLegacySymbols(hostBuilder);

this.Add(new InstantiateCommand(this, hostBuilder));
this.Add(new InstallCommand(this, hostBuilder));
this.Add(new UninstallCommand(this, hostBuilder));
this.Add(new UpdateCommand(this, hostBuilder));
this.Add(new SearchCommand(this, hostBuilder));
this.Add(new ListCommand(this, hostBuilder));
this.Add(new AliasCommand(hostBuilder));
this.Add(new DetailsCommand(hostBuilder));

this.Options.Add(DebugCustomSettingsLocationOption);
this.Options.Add(DebugVirtualizeSettingsOption);
this.Options.Add(DebugAttachOption);
this.Options.Add(DebugReinitOption);
this.Options.Add(DebugRebuildCacheOption);
this.Options.Add(DebugShowConfigOption);

this.Options.Add(SharedOptions.OutputOption);
this.Options.Add(SharedOptions.NameOption);
this.Options.Add(SharedOptions.DryRunOption);
this.Options.Add(SharedOptions.ForceOption);
this.Options.Add(SharedOptions.NoUpdateCheckOption);
this.Options.Add(SharedOptions.ProjectPathOption);
Add(new InstantiateCommand(this, hostBuilder));
Add(new InstallCommand(this, hostBuilder));
Add(new UninstallCommand(this, hostBuilder));
Add(new UpdateCommand(this, hostBuilder));
Add(new SearchCommand(this, hostBuilder));
Add(new ListCommand(this, hostBuilder));
Add(new AliasCommand(hostBuilder));
Add(new DetailsCommand(hostBuilder));

Options.Add(DebugCustomSettingsLocationOption);
Options.Add(DebugVirtualizeSettingsOption);
Options.Add(DebugAttachOption);
Options.Add(DebugReinitOption);
Options.Add(DebugRebuildCacheOption);
Options.Add(DebugShowConfigOption);

Options.Add(SharedOptions.OutputOption);
Options.Add(SharedOptions.NameOption);
Options.Add(SharedOptions.DryRunOption);
Options.Add(SharedOptions.ForceOption);
Options.Add(SharedOptions.NoUpdateCheckOption);
Options.Add(SharedOptions.ProjectPathOption);
}

internal static CliOption<string?> DebugCustomSettingsLocationOption { get; } = new("--debug:custom-hive")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ internal AliasCommand(
: base(hostBuilder, "alias", SymbolStrings.Command_Alias_Description)
{
Hidden = true;
this.Add(new AliasAddCommand(hostBuilder));
this.Add(new AliasShowCommand(hostBuilder));
Add(new AliasAddCommand(hostBuilder));
Add(new AliasShowCommand(hostBuilder));
}

protected override Task<NewCommandStatus> ExecuteAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ internal InstantiateCommand(
Func<ParseResult, ITemplateEngineHost> hostBuilder)
: base(hostBuilder, "create", SymbolStrings.Command_Instantiate_Description)
{
this.Arguments.Add(ShortNameArgument);
this.Arguments.Add(RemainingArguments);
Arguments.Add(ShortNameArgument);
Arguments.Add(RemainingArguments);

this.Options.Add(SharedOptions.OutputOption);
this.Options.Add(SharedOptions.NameOption);
this.Options.Add(SharedOptions.DryRunOption);
this.Options.Add(SharedOptions.ForceOption);
this.Options.Add(SharedOptions.NoUpdateCheckOption);
this.Options.Add(SharedOptions.ProjectPathOption);
Options.Add(SharedOptions.OutputOption);
Options.Add(SharedOptions.NameOption);
Options.Add(SharedOptions.DryRunOption);
Options.Add(SharedOptions.ForceOption);
Options.Add(SharedOptions.NoUpdateCheckOption);
Options.Add(SharedOptions.ProjectPathOption);

parentCommand.AddNoLegacyUsageValidators(this);
this.Validators.Add(symbolResult => parentCommand.ValidateOptionUsage(symbolResult, SharedOptions.OutputOption));
this.Validators.Add(symbolResult => parentCommand.ValidateOptionUsage(symbolResult, SharedOptions.NameOption));
this.Validators.Add(symbolResult => parentCommand.ValidateOptionUsage(symbolResult, SharedOptions.DryRunOption));
this.Validators.Add(symbolResult => parentCommand.ValidateOptionUsage(symbolResult, SharedOptions.ForceOption));
this.Validators.Add(symbolResult => parentCommand.ValidateOptionUsage(symbolResult, SharedOptions.NoUpdateCheckOption));
this.Validators.Add(symbolResult => parentCommand.ValidateOptionUsage(symbolResult, SharedOptions.ProjectPathOption));
Validators.Add(symbolResult => parentCommand.ValidateOptionUsage(symbolResult, SharedOptions.OutputOption));
Validators.Add(symbolResult => parentCommand.ValidateOptionUsage(symbolResult, SharedOptions.NameOption));
Validators.Add(symbolResult => parentCommand.ValidateOptionUsage(symbolResult, SharedOptions.DryRunOption));
Validators.Add(symbolResult => parentCommand.ValidateOptionUsage(symbolResult, SharedOptions.ForceOption));
Validators.Add(symbolResult => parentCommand.ValidateOptionUsage(symbolResult, SharedOptions.NoUpdateCheckOption));
Validators.Add(symbolResult => parentCommand.ValidateOptionUsage(symbolResult, SharedOptions.ProjectPathOption));
}

internal static CliArgument<string> ShortNameArgument { get; } = new CliArgument<string>("template-short-name")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public override int GetHashCode()

public bool Equals(InvalidTemplateOptionResult? other)
{
return this.Equals(other as object);
return Equals(other as object);
}

internal static InvalidTemplateOptionResult FromParseError(TemplateOption option, ParseResult parseResult, ParseError error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public TemplateCommand(
Aliases.Add(item);
}

this.Options.Add(SharedOptions.OutputOption);
this.Options.Add(SharedOptions.NameOption);
this.Options.Add(SharedOptions.DryRunOption);
this.Options.Add(SharedOptions.ForceOption);
this.Options.Add(SharedOptions.NoUpdateCheckOption);
Options.Add(SharedOptions.OutputOption);
Options.Add(SharedOptions.NameOption);
Options.Add(SharedOptions.DryRunOption);
Options.Add(SharedOptions.ForceOption);
Options.Add(SharedOptions.NoUpdateCheckOption);

string? templateLanguage = template.GetLanguage();
string? defaultLanguage = environmentSettings.GetDefaultLanguage();
Expand All @@ -77,7 +77,7 @@ public TemplateCommand(
}
);
}
this.Options.Add(LanguageOption);
Options.Add(LanguageOption);
}

string? templateType = template.GetTemplateType();
Expand All @@ -87,15 +87,15 @@ public TemplateCommand(
TypeOption = SharedOptionsFactory.CreateTypeOption();
TypeOption.Description = SymbolStrings.TemplateCommand_Option_Type;
TypeOption.FromAmongCaseInsensitive(new[] { templateType });
this.Options.Add(TypeOption);
Options.Add(TypeOption);
}

if (template.BaselineInfo.Any(b => !string.IsNullOrWhiteSpace(b.Key)))
{
BaselineOption = SharedOptionsFactory.CreateBaselineOption();
BaselineOption.Description = SymbolStrings.TemplateCommand_Option_Baseline;
BaselineOption.FromAmongCaseInsensitive(template.BaselineInfo.Select(b => b.Key).Where(b => !string.IsNullOrWhiteSpace(b)).ToArray());
this.Options.Add(BaselineOption);
Options.Add(BaselineOption);
}

if (HasRunScriptPostActionDefined(template))
Expand All @@ -106,7 +106,7 @@ public TemplateCommand(
Arity = new ArgumentArity(1, 1)
};
AllowScriptsOption.DefaultValueFactory = (_) => AllowRunScripts.Prompt;
this.Options.Add(AllowScriptsOption);
Options.Add(AllowScriptsOption);
}

AddTemplateOptionsToCommand(template);
Expand Down Expand Up @@ -311,7 +311,7 @@ private void AddTemplateOptionsToCommand(CliTemplateInfo templateInfo)
foreach ((CliTemplateParameter parameter, IReadOnlySet<string> aliases, IReadOnlyList<string> _) in parametersWithAliasAssignments)
{
TemplateOption option = new TemplateOption(parameter, aliases);
this.Options.Add(option.Option);
Options.Add(option.Option);
_templateSpecificOptions[parameter.Name] = option;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ internal BaseInstallCommand(
: base(hostBuilder, commandName, SymbolStrings.Command_Install_Description)
{
ParentCommand = parentCommand;
this.Arguments.Add(NameArgument);
this.Options.Add(InteractiveOption);
this.Options.Add(AddSourceOption);
this.Options.Add(ForceOption);
Arguments.Add(NameArgument);
Options.Add(InteractiveOption);
Options.Add(AddSourceOption);
Options.Add(ForceOption);
}

internal static CliArgument<string[]> NameArgument { get; } = new("package")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ internal class LegacyInstallCommand : BaseInstallCommand
public LegacyInstallCommand(NewCommand parentCommand, Func<ParseResult, ITemplateEngineHost> hostBuilder)
: base(parentCommand, hostBuilder, "--install")
{
this.Hidden = true;
this.Aliases.Add("-i");
Hidden = true;
Aliases.Add("-i");

parentCommand.AddNoLegacyUsageValidators(this, except: new CliOption[] { InteractiveOption, AddSourceOption });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ internal BaseListCommand(
ParentCommand = parentCommand;
Filters = SetupFilterOptions(SupportedFilters);

this.Arguments.Add(NameArgument);
this.Options.Add(IgnoreConstraintsOption);
this.Options.Add(SharedOptions.OutputOption);
this.Options.Add(SharedOptions.ProjectPathOption);
Arguments.Add(NameArgument);
Options.Add(IgnoreConstraintsOption);
Options.Add(SharedOptions.OutputOption);
Options.Add(SharedOptions.ProjectPathOption);
SetupTabularOutputOptions(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public LegacyListCommand(
Func<ParseResult, ITemplateEngineHost> hostBuilder)
: base(parentCommand, hostBuilder, "--list")
{
this.Hidden = true;
this.Aliases.Add("-l");
this.Validators.Add(ValidateParentCommandArguments);
Hidden = true;
Aliases.Add("-l");
Validators.Add(ValidateParentCommandArguments);

parentCommand.AddNoLegacyUsageValidators(this, except: Filters.Values.Concat(new CliSymbol[] { ColumnsAllOption, ColumnsOption, NewCommand.ShortNameArgument }).ToArray());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal BaseSearchCommand(
ParentCommand = parentCommand;
Filters = SetupFilterOptions(SupportedFilters);

this.Arguments.Add(NameArgument);
Arguments.Add(NameArgument);
SetupTabularOutputOptions(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ internal class LegacySearchCommand : BaseSearchCommand
public LegacySearchCommand(NewCommand parentCommand, Func<ParseResult, ITemplateEngineHost> hostBuilder)
: base(parentCommand, hostBuilder, "--search")
{
this.Hidden = true;
this.Validators.Add(ValidateParentCommandArguments);
Hidden = true;
Validators.Add(ValidateParentCommandArguments);

parentCommand.AddNoLegacyUsageValidators(this, except: Filters.Values.Concat(new CliSymbol[] { ColumnsAllOption, ColumnsOption, NewCommand.ShortNameArgument }).ToArray());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal BaseUninstallCommand(
string commandName)
: base(hostBuilder, commandName, SymbolStrings.Command_Uninstall_Description)
{
this.Arguments.Add(NameArgument);
Arguments.Add(NameArgument);
}

internal static CliArgument<string[]> NameArgument { get; } = new("package")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public LegacyUninstallCommand(
Func<ParseResult, ITemplateEngineHost> hostBuilder)
: base(hostBuilder, "--uninstall")
{
this.Hidden = true;
this.Aliases.Add("-u");
Hidden = true;
Aliases.Add("-u");

parentCommand.AddNoLegacyUsageValidators(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ internal BaseUpdateCommand(
: base(hostBuilder, commandName, description)
{
ParentCommand = parentCommand;
this.Options.Add(InteractiveOption);
this.Options.Add(AddSourceOption);
Options.Add(InteractiveOption);
Options.Add(AddSourceOption);
}

internal virtual CliOption<bool> InteractiveOption { get; } = SharedOptionsFactory.CreateInteractiveOption();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public LegacyUpdateApplyCommand(
Func<ParseResult, ITemplateEngineHost> hostBuilder)
: base(parentCommand, hostBuilder, "--update-apply", SymbolStrings.Command_Legacy_Update_Check_Description)
{
this.Hidden = true;
Hidden = true;
parentCommand.AddNoLegacyUsageValidators(this, except: new CliOption[] { InteractiveOption, AddSourceOption });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public LegacyUpdateCheckCommand(
Func<ParseResult, ITemplateEngineHost> hostBuilder)
: base(parentCommand, hostBuilder, "--update-check", SymbolStrings.Command_Update_Description)
{
this.Hidden = true;
Hidden = true;
parentCommand.AddNoLegacyUsageValidators(this, except: new CliOption[] { InteractiveOption, AddSourceOption });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public UpdateCommand(
: base(parentCommand, hostBuilder, "update", SymbolStrings.Command_Update_Description)
{
parentCommand.AddNoLegacyUsageValidators(this);
this.Options.Add(CheckOnlyOption);
Options.Add(CheckOnlyOption);
}

internal static CliOption<bool> CheckOnlyOption { get; } = new("--check-only", "--dry-run")
Expand Down
8 changes: 4 additions & 4 deletions src/Cli/dotnet-new3/CompleteCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ internal class CompleteCommand : CliCommand

internal CompleteCommand() : base("complete", "tab completion")
{
this.Arguments.Add(PathArgument);
this.Options.Add(PositionOption);
Arguments.Add(PathArgument);
Options.Add(PositionOption);

this.SetAction(Run);
this.Hidden = true;
SetAction(Run);
Hidden = true;
}

public Task<int> Run(ParseResult result, CancellationToken cancellationToken)
Expand Down
Loading
Loading