Skip to content

Commit bb3ef55

Browse files
mitchdennydavidfowl
andcommitted
Adding descriptions to all args/options in CLI. (#8544)
* Adding descriptions to all args/options in CLI. * Revert project arg to option. * PR feedback. * Rename resource to integration. * Update src/Aspire.Cli/Commands/RunCommand.cs Co-authored-by: David Fowler <davidfowl@gmail.com> --------- Co-authored-by: David Fowler <davidfowl@gmail.com>
1 parent ae94e55 commit bb3ef55

File tree

5 files changed

+31
-9
lines changed

5 files changed

+31
-9
lines changed

src/Aspire.Cli/Commands/AddCommand.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,34 @@ internal sealed class AddCommand : BaseCommand
1515
private readonly DotNetCliRunner _runner;
1616
private readonly INuGetPackageCache _nuGetPackageCache;
1717

18-
public AddCommand(DotNetCliRunner runner, INuGetPackageCache nuGetPackageCache) : base("add", "Add an integration or other resource to the Aspire project.")
18+
public AddCommand(DotNetCliRunner runner, INuGetPackageCache nuGetPackageCache)
19+
: base("add", "Add an integration to the Aspire project.")
1920
{
2021
ArgumentNullException.ThrowIfNull(runner, nameof(runner));
2122
ArgumentNullException.ThrowIfNull(nuGetPackageCache, nameof(nuGetPackageCache));
2223
_runner = runner;
2324
_nuGetPackageCache = nuGetPackageCache;
2425

25-
var resourceArgument = new Argument<string>("resource");
26-
resourceArgument.Arity = ArgumentArity.ZeroOrOne;
27-
Arguments.Add(resourceArgument);
26+
var integrationArgument = new Argument<string>("integration");
27+
integrationArgument.Description = "The name of the integration to add (e.g. redis, postgres).";
28+
integrationArgument.Arity = ArgumentArity.ZeroOrOne;
29+
Arguments.Add(integrationArgument);
2830

2931
var projectOption = new Option<FileInfo?>("--project");
32+
projectOption.Description = "The path to the project file to add the integration to.";
3033
projectOption.Validators.Add(ProjectFileHelper.ValidateProjectOption);
3134
Options.Add(projectOption);
3235

3336
var versionOption = new Option<string>("--version", "-v");
37+
versionOption.Description = "The version of the integration to add.";
3438
Options.Add(versionOption);
3539

3640
var prereleaseOption = new Option<bool>("--prerelease");
41+
prereleaseOption.Description = "Include pre-release versions of the integration when searching.";
3742
Options.Add(prereleaseOption);
3843

3944
var sourceOption = new Option<string?>("--source", "-s");
45+
sourceOption.Description = "The NuGet source to use for the integration.";
4046
Options.Add(sourceOption);
4147
}
4248

@@ -46,7 +52,7 @@ protected override async Task<int> ExecuteAsync(ParseResult parseResult, Cancell
4652

4753
try
4854
{
49-
var integrationName = parseResult.GetValue<string>("resource");
55+
var integrationName = parseResult.GetValue<string>("integration");
5056

5157
var passedAppHostProjectFile = parseResult.GetValue<FileInfo?>("--project");
5258
var effectiveAppHostProjectFile = ProjectFileHelper.UseOrFindAppHostProjectFile(passedAppHostProjectFile);

src/Aspire.Cli/Commands/NewCommand.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,33 @@ internal sealed class NewCommand : BaseCommand
1515
private readonly DotNetCliRunner _runner;
1616
private readonly INuGetPackageCache _nuGetPackageCache;
1717

18-
public NewCommand(DotNetCliRunner runner, INuGetPackageCache nuGetPackageCache) : base("new", "Create a new Aspire sample project.")
18+
public NewCommand(DotNetCliRunner runner, INuGetPackageCache nuGetPackageCache)
19+
: base("new", "Create a new Aspire sample project.")
1920
{
2021
ArgumentNullException.ThrowIfNull(runner, nameof(runner));
2122
ArgumentNullException.ThrowIfNull(nuGetPackageCache, nameof(nuGetPackageCache));
2223
_runner = runner;
2324
_nuGetPackageCache = nuGetPackageCache;
2425

2526
var templateArgument = new Argument<string>("template");
27+
templateArgument.Description = "The name of the project template to use (e.g. aspire-starter, aspire).";
2628
templateArgument.Arity = ArgumentArity.ZeroOrOne;
2729
Arguments.Add(templateArgument);
2830

2931
var nameOption = new Option<string>("--name", "-n");
32+
nameOption.Description = "The name of the project to create.";
3033
Options.Add(nameOption);
3134

3235
var outputOption = new Option<string?>("--output", "-o");
36+
outputOption.Description = "The output path for the project.";
3337
Options.Add(outputOption);
3438

3539
var sourceOption = new Option<string?>("--source", "-s");
40+
sourceOption.Description = "The NuGet source to use for the project templates.";
3641
Options.Add(sourceOption);
3742

3843
var templateVersionOption = new Option<string?>("--version", "-v");
44+
templateVersionOption.Description = "The version of the project templates to use.";
3945
Options.Add(templateVersionOption);
4046
}
4147

src/Aspire.Cli/Commands/PublishCommand.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,23 @@ internal sealed class PublishCommand : BaseCommand
1515
private readonly ActivitySource _activitySource = new ActivitySource(nameof(PublishCommand));
1616
private readonly DotNetCliRunner _runner;
1717

18-
public PublishCommand(DotNetCliRunner runner) : base("publish", "Generates deployment artifacts for an Aspire app host project.")
18+
public PublishCommand(DotNetCliRunner runner)
19+
: base("publish", "Generates deployment artifacts for an Aspire app host project.")
1920
{
2021
ArgumentNullException.ThrowIfNull(runner, nameof(runner));
2122
_runner = runner;
2223

2324
var projectOption = new Option<FileInfo?>("--project");
25+
projectOption.Description = "The path to the Aspire app host project file.";
2426
projectOption.Validators.Add(ProjectFileHelper.ValidateProjectOption);
2527
Options.Add(projectOption);
2628

2729
var publisherOption = new Option<string>("--publisher", "-p");
30+
publisherOption.Description = "The name of the publisher to use.";
2831
Options.Add(publisherOption);
2932

3033
var outputPath = new Option<string>("--output-path", "-o");
34+
outputPath.Description = "The output path for the generated artifacts.";
3135
outputPath.DefaultValueFactory = (result) => Path.Combine(Environment.CurrentDirectory);
3236
Options.Add(outputPath);
3337
}

src/Aspire.Cli/Commands/RootCommand.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ namespace Aspire.Cli.Commands;
1414

1515
internal sealed class RootCommand : BaseRootCommand
1616
{
17-
public RootCommand(NewCommand newCommand, RunCommand runCommand, AddCommand addCommand, PublishCommand publishCommand) : base("Aspire CLI")
17+
public RootCommand(NewCommand newCommand, RunCommand runCommand, AddCommand addCommand, PublishCommand publishCommand)
18+
: base("The Aspire CLI can be used to create, run, and publish Aspire-based applications.")
1819
{
1920
var debugOption = new Option<bool>("--debug", "-d");
21+
debugOption.Description = "Enable debug logging to the console.";
2022
debugOption.Recursive = true;
2123
Options.Add(debugOption);
2224

2325
var waitForDebuggerOption = new Option<bool>("--wait-for-debugger", "-w");
26+
waitForDebuggerOption.Description = "Wait for a debugger to attach before executing the command.";
2427
waitForDebuggerOption.Recursive = true;
2528
waitForDebuggerOption.DefaultValueFactory = (result) => false;
2629

src/Aspire.Cli/Commands/RunCommand.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,20 @@ internal sealed class RunCommand : BaseCommand
1717
private readonly ActivitySource _activitySource = new ActivitySource(nameof(RunCommand));
1818
private readonly DotNetCliRunner _runner;
1919

20-
public RunCommand(DotNetCliRunner runner) : base("run", "Run an Aspire app host in development mode.")
20+
public RunCommand(DotNetCliRunner runner)
21+
: base("run", "Run an Aspire app host in development mode.")
2122
{
2223
ArgumentNullException.ThrowIfNull(runner, nameof(runner));
2324

2425
_runner = runner;
2526

2627
var projectOption = new Option<FileInfo?>("--project");
28+
projectOption.Description = "The path to the Aspire app host project file.";
2729
projectOption.Validators.Add(ProjectFileHelper.ValidateProjectOption);
2830
Options.Add(projectOption);
2931

3032
var watchOption = new Option<bool>("--watch", "-w");
33+
watchOption.Description = "Start project resources in watch mode.";
3134
Options.Add(watchOption);
3235
}
3336

0 commit comments

Comments
 (0)