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

[main] Update dependencies from dotnet/command-line-api #29131

Merged
merged 96 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from 89 commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
5a564e2
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Nov 18, 2022
33ae728
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Nov 18, 2022
5981597
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Dec 13, 2022
68dda8a
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Jan 19, 2023
fa49eae
adopt to recent breaking changes: renames, removal of extension methods
adamsitnik Jan 20, 2023
bb036dd
adopt to recent breaking changes: removal of Children property
adamsitnik Jan 20, 2023
76d51bb
reduce lambda allocations
adamsitnik Jan 20, 2023
c12b639
adopt to recent breaking changes: SetDefaultValue is now avilable onl…
adamsitnik Jan 20, 2023
358676c
Merge branch 'main' into darc-main-d950046d-c6ae-4e82-ad57-55ddf2973d18
adamsitnik Jan 20, 2023
4c8a5f4
address one of the discovered problems
adamsitnik Jan 20, 2023
dd5e233
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Jan 20, 2023
03c78e4
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Jan 20, 2023
0be3134
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Jan 23, 2023
397544b
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Feb 2, 2023
8a8e7d8
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Feb 2, 2023
7268413
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Feb 2, 2023
91f6fab
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Feb 3, 2023
83f227b
Merge branch 'main' of https://github.com/dotnet/sdk into darc-main-d…
v-wuzhai Feb 9, 2023
3f1c10c
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Feb 13, 2023
8c12a78
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Feb 18, 2023
fe6e02b
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Feb 22, 2023
4e99936
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Feb 22, 2023
46d264c
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 2, 2023
6bec365
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 7, 2023
ecea358
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 7, 2023
7deda76
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 8, 2023
0f80fca
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 13, 2023
37a7d3c
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 14, 2023
113fe8f
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 14, 2023
1af00d5
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 15, 2023
c45ae0e
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 15, 2023
c145b9e
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 16, 2023
83e6b29
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 16, 2023
e7d3f2d
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 18, 2023
5e200a7
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 20, 2023
c91fc88
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 21, 2023
213425d
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 21, 2023
5188b5d
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 22, 2023
7ba6711
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 24, 2023
a0e0cbc
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 28, 2023
82496ce
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 28, 2023
167fccf
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 28, 2023
d1f4cd3
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 29, 2023
0669ec2
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 29, 2023
32538df
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 29, 2023
70330ff
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 29, 2023
d4f3b5f
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 30, 2023
799d1d6
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 31, 2023
9143238
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 31, 2023
585e936
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 31, 2023
c03f5a5
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 31, 2023
7ddfa93
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Mar 31, 2023
8b78b37
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Apr 3, 2023
ed5f5c5
update to the latest version 1/N
adamsitnik Apr 3, 2023
504c3d8
update to the latest version 2/N
adamsitnik Apr 4, 2023
b58ff13
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Apr 5, 2023
9da3bc4
update to the latest version 3/N
adamsitnik Apr 5, 2023
81bb95b
fix the tests:
adamsitnik Apr 6, 2023
cb2a35f
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Apr 10, 2023
422c6cf
Merge remote-tracking branch 'origin/main' into darc-main-d950046d-c6…
adamsitnik Apr 10, 2023
20ec900
Merge branch 'darc-main-d950046d-c6ae-4e82-ad57-55ddf2973d18' of http…
adamsitnik Apr 10, 2023
87bfeb8
Merge remote-tracking branch 'origin/main' into darc-main-d950046d-c6…
adamsitnik Apr 10, 2023
0b34d1d
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Apr 11, 2023
1e1e775
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Apr 12, 2023
a36ba0b
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Apr 13, 2023
97b5d95
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Apr 13, 2023
1616c72
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Apr 14, 2023
4f6c29b
Merge branch 'main' into darc-main-d950046d-c6ae-4e82-ad57-55ddf2973d18
lewing Apr 15, 2023
00c79b2
adjust to most recent changes
adamsitnik Apr 16, 2023
af5f0fb
Update Versions.props
mmitche Apr 16, 2023
69f8f21
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Apr 19, 2023
4a1ba6f
test fixes:
adamsitnik Apr 19, 2023
a850d5e
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Apr 20, 2023
c4ab1cf
Merge branch 'main' of https://github.com/dotnet/sdk into darc-main-d…
v-wuzhai Apr 21, 2023
2125ad6
Merge branch 'main' into darc-main-d950046d-c6ae-4e82-ad57-55ddf2973d18
lewing Apr 26, 2023
62135f0
Update WorkloadUninstallCommandParser.cs
lewing Apr 26, 2023
db8f5b9
Update SlnListParser.cs
lewing Apr 26, 2023
27a8a30
Fix constructor call
lewing Apr 26, 2023
85fecce
Merge branch 'main' into darc-main-d950046d-c6ae-4e82-ad57-55ddf2973d18
YuliiaKovalova Apr 26, 2023
fb73afe
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] May 17, 2023
fa67214
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] May 19, 2023
69ce4c8
Merge remote-tracking branch 'origin/main' into darc-main-d950046d-c6…
adamsitnik May 31, 2023
08e0ea4
test fixes:
adamsitnik Jun 1, 2023
7ae744f
test fixes:
adamsitnik Jun 2, 2023
e3195bc
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Jun 2, 2023
cb165bf
Merge branch 'main' into darc-main-d950046d-c6ae-4e82-ad57-55ddf2973d18
JL03-Yue Jun 5, 2023
954b461
test fixes:
adamsitnik Jun 5, 2023
4ba2339
test fixes:
adamsitnik Jun 6, 2023
18dff4b
Merge branch 'main' into darc-main-d950046d-c6ae-4e82-ad57-55ddf2973d18
adamsitnik Jun 6, 2023
2c6f23b
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Jun 6, 2023
4daa474
Merge remote-tracking branch 'origin/main' into darc-main-d950046d-c6…
adamsitnik Jun 7, 2023
b21ccca
address code review feedback: restore var to get smaller diff
adamsitnik Jun 7, 2023
6bc18d3
address code review feedback: use HelpName to avoid help output changes
adamsitnik Jun 7, 2023
ceb0610
Merge remote-tracking branch 'origin/main' into darc-main-d950046d-c6…
adamsitnik Jun 7, 2023
d1d3d4e
Update dependencies from https://github.com/dotnet/command-line-api b…
dotnet-maestro[bot] Jun 8, 2023
c5b54eb
test fixes:
adamsitnik Jun 8, 2023
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
8 changes: 4 additions & 4 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,13 @@
<Sha>2b6ab8d727ce73a78bcbf026ac75ea8a7c804daf</Sha>
<SourceBuild RepoName="roslyn-analyzers" ManagedOnly="true" />
</Dependency>
<Dependency Name="System.CommandLine" Version="2.0.0-beta4.22564.1">
<Dependency Name="System.CommandLine" Version="2.0.0-beta4.23302.1">
<Uri>https://github.com/dotnet/command-line-api</Uri>
<Sha>8374d5fca634a93458c84414b1604c12f765d1ab</Sha>
<Sha>e678d32595c943e2c4b424eecc03b43f8265be82</Sha>
</Dependency>
<Dependency Name="Microsoft.SourceBuild.Intermediate.command-line-api" Version="0.1.356401">
<Dependency Name="Microsoft.SourceBuild.Intermediate.command-line-api" Version="0.1.430201">
<Uri>https://github.com/dotnet/command-line-api</Uri>
<Sha>8374d5fca634a93458c84414b1604c12f765d1ab</Sha>
<Sha>e678d32595c943e2c4b424eecc03b43f8265be82</Sha>
<SourceBuild RepoName="command-line-api" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-externals" Version="8.0.0-alpha.1.23301.1">
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<SystemTextJsonVersion>7.0.2</SystemTextJsonVersion>
<SystemReflectionMetadataLoadContextVersion>8.0.0-preview.6.23304.2</SystemReflectionMetadataLoadContextVersion>
<SystemManagementPackageVersion>4.6.0</SystemManagementPackageVersion>
<SystemCommandLineVersion>2.0.0-beta4.22564.1</SystemCommandLineVersion>
<SystemCommandLineVersion>2.0.0-beta4.23302.1</SystemCommandLineVersion>
<MicrosoftDeploymentDotNetReleasesVersion>1.0.0-preview.6.23206.1</MicrosoftDeploymentDotNetReleasesVersion>
<MicrosoftVisualStudioSetupConfigurationInteropVersion>3.2.2146</MicrosoftVisualStudioSetupConfigurationInteropVersion>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static void Run(Func<ISuppressionEngine, ISuppressableLog> logFactory,
bool enableRuleAttributesMustMatch,
string[]? excludeAttributesFiles,
bool enableRuleCannotChangeParameterName,
string packagePath,
string? packagePath,
bool runApiCompat,
bool enableStrictModeForCompatibleTfms,
bool enableStrictModeForCompatibleFrameworksInPackage,
Expand Down
346 changes: 192 additions & 154 deletions src/ApiCompat/Microsoft.DotNet.ApiCompat.Tool/Program.cs

Large diffs are not rendered by default.

36 changes: 16 additions & 20 deletions src/BlazorWasmSdk/Tool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
using System;
using System.Collections.Generic;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.CommandLine.Parsing;
using System.IO;
using System.IO.Compression;
using System.Threading.Tasks;
Expand All @@ -16,23 +14,22 @@ internal static class Program
{
public static int Main(string[] args)
{
var rootCommand = new RootCommand();
var brotli = new Command("brotli");
CliRootCommand rootCommand = new();
CliCommand brotli = new("brotli");

var compressionLevelOption = new Option<CompressionLevel>(
"-c",
defaultValueFactory: () => CompressionLevel.SmallestSize,
description: "System.IO.Compression.CompressionLevel for the Brotli compression algorithm.");
var sourcesOption = new Option<List<string>>(
"-s",
description: "A list of files to compress.")
CliOption<CompressionLevel> compressionLevelOption = new("-c")
{
DefaultValueFactory = _ => CompressionLevel.SmallestSize,
Description = "System.IO.Compression.CompressionLevel for the Brotli compression algorithm.",
};
CliOption<List<string>> sourcesOption = new("-s")
{
Description = "A list of files to compress.",
AllowMultipleArgumentsPerToken = false
};
var outputsOption = new Option<List<string>>(
"-o",
"The filenames to output the compressed file to.")
CliOption<List<string>> outputsOption = new("-o")
{
Description = "The filenames to output the compressed file to.",
AllowMultipleArgumentsPerToken = false
};

Expand All @@ -42,12 +39,11 @@ public static int Main(string[] args)

rootCommand.Add(brotli);

brotli.SetHandler((InvocationContext context) =>
brotli.SetAction((ParseResult parseResult) =>
{
var parseResults = context.ParseResult;
var c = parseResults.GetValue(compressionLevelOption);
var s = parseResults.GetValue(sourcesOption);
var o = parseResults.GetValue(outputsOption);
var c = parseResult.GetValue(compressionLevelOption);
var s = parseResult.GetValue(sourcesOption);
var o = parseResult.GetValue(outputsOption);

Parallel.For(0, s.Count, i =>
{
Expand All @@ -69,7 +65,7 @@ public static int Main(string[] args)
});
});

return rootCommand.InvokeAsync(args).Result;
return rootCommand.Parse(args).Invoke();
baronfel marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
138 changes: 80 additions & 58 deletions src/BuiltInTools/dotnet-watch/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
using System;
using System.Collections.Generic;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.IO;
using System.Linq;

using Microsoft.AspNetCore.Authentication;
using Microsoft.DotNet.Watcher.Tools;
using Microsoft.Extensions.Tools.Internal;

Expand Down Expand Up @@ -77,112 +75,131 @@ dotnet watch test
public required IReadOnlyList<string> RemainingArguments { get; init; }
public RunCommandLineOptions? RunOptions { get; init; }

public static CommandLineOptions? Parse(string[] args, IReporter reporter, out int errorCode, System.CommandLine.IConsole? console = null)
public static CommandLineOptions? Parse(string[] args, IReporter reporter, out int errorCode, TextWriter? output = null, TextWriter? error = null)
{
var quietOption = new Option<bool>(new[] { "--quiet", "-q" }, "Suppresses all output except warnings and errors");
var verboseOption = new Option<bool>(new[] { "--verbose", "-v" }, "Show verbose output");
CliOption<bool> quietOption = new("--quiet", "-q")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please keep the previous style, i.e. var _ = new CliOption<bool>(...) instead of CliOption<bool> _ = new(...)? It'd be a) easier to read the PR and b) consistent with https://github.com/dotnet/sdk/pull/29131/files#diff-48c696e38dedfa782c9bb14f1e5749d861c4cd6ae825edda9497bb62deebdc3cR146

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tmat I apology, I should not bring my var obsession from dotnet/runtime to this repo.

Changing that is possible, but it would take me quite a lot of time (I could automate it only partially) for the entire solution. Unless you are concerned about only this particular file?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just this particular file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tmat done, PTAL

{
Description = "Suppresses all output except warnings and errors"
};

verboseOption.AddValidator(v =>
CliOption<bool> verboseOption = new("--verbose", "-v")
{
if (v.FindResultFor(quietOption) is not null && v.FindResultFor(verboseOption) is not null)
Description = "Show verbose output"
};

verboseOption.Validators.Add(v =>
{
if (v.GetResult(quietOption) is not null && v.GetResult(verboseOption) is not null)
{
v.ErrorMessage = Resources.Error_QuietAndVerboseSpecified;
v.AddError(Resources.Error_QuietAndVerboseSpecified);
}
});

var listOption = new Option<bool>("--list", "Lists all discovered files without starting the watcher.");
var shortProjectOption = new Option<string>("-p", "The project to watch.") { IsHidden = true };
var longProjectOption = new Option<string>("--project", "The project to watch");
CliOption<bool> listOption = new("--list") { Description = "Lists all discovered files without starting the watcher." };
CliOption<string> shortProjectOption = new("-p") { Description = "The project to watch.", Hidden = true };
CliOption<string> longProjectOption = new("--project") { Description = "The project to watch" };

// launch profile used by dotnet-watch
var launchProfileWatchOption = new Option<string>(new[] { "-lp", LaunchProfileOptionName }, "The launch profile to start the project with (case-sensitive).");
var noLaunchProfileWatchOption = new Option<bool>(new[] { NoLaunchProfileOptionName }, "Do not attempt to use launchSettings.json to configure the application.");
CliOption<string> launchProfileWatchOption = new(LaunchProfileOptionName, "-lp")
{
Description = "The launch profile to start the project with (case-sensitive)."
};
CliOption<bool> noLaunchProfileWatchOption = new(NoLaunchProfileOptionName)
{
Description = "Do not attempt to use launchSettings.json to configure the application."
};

// launch profile used by dotnet-run
var launchProfileRunOption = new Option<string>(new[] { "-lp", LaunchProfileOptionName }) { IsHidden = true };
var noLaunchProfileRunOption = new Option<bool>(new[] { NoLaunchProfileOptionName }) { IsHidden = true };
CliOption<string> launchProfileRunOption = new (LaunchProfileOptionName, "-lp") { Hidden = true };
CliOption<bool> noLaunchProfileRunOption = new(NoLaunchProfileOptionName) { Hidden = true };

var targetFrameworkOption = new Option<string>(new[] { "-f", "--framework" }, "The target framework to run for. The target framework must also be specified in the project file.");
var propertyOption = new Option<string[]>(new[] { "--property" }, "Properties to be passed to MSBuild.");
CliOption<string> targetFrameworkOption = new("--framework", "-f")
{
Description = "The target framework to run for. The target framework must also be specified in the project file."
};
CliOption<string[]> propertyOption = new("--property")
{
Description = "Properties to be passed to MSBuild."
};

propertyOption.AddValidator(v =>
propertyOption.Validators.Add(v =>
{
var invalidProperty = v.GetValue(propertyOption)?.FirstOrDefault(
property => !(property.IndexOf('=') is > 0 and var index && index < property.Length - 1 && property[..index].Trim().Length > 0));

if (invalidProperty != null)
{
v.ErrorMessage = $"Invalid property format: '{invalidProperty}'. Expected 'name=value'.";
v.AddError($"Invalid property format: '{invalidProperty}'. Expected 'name=value'.");
}
});

var noHotReloadOption = new Option<bool>("--no-hot-reload", "Suppress hot reload for supported apps.");
var nonInteractiveOption = new Option<bool>(
"--non-interactive",
"Runs dotnet-watch in non-interactive mode. This option is only supported when running with Hot Reload enabled. " +
"Use this option to prevent console input from being captured.");
CliOption<bool> noHotReloadOption = new("--no-hot-reload") { Description = "Suppress hot reload for supported apps." };
CliOption<bool> nonInteractiveOption = new("--non-interactive")
{
Description = "Runs dotnet-watch in non-interactive mode. This option is only supported when running with Hot Reload enabled. " +
"Use this option to prevent console input from being captured."
};

var remainingWatchArgs = new Argument<string[]>("forwardedArgs", "Arguments to pass to the child dotnet process.");
var remainingRunArgs = new Argument<string[]>(name: null);
CliArgument<string[]> remainingWatchArgs = new("forwardedArgs") { Description = "Arguments to pass to the child dotnet process." };
CliArgument<string[]> remainingRunArgs = new ("remainingRunArgs");

var runCommand = new Command("run") { IsHidden = true };
var rootCommand = new RootCommand(Description);
addOptions(runCommand);
addOptions(rootCommand);
var runCommand = new CliCommand("run") { Hidden = true };
var rootCommand = new CliRootCommand(Description);
AddSymbols(runCommand);
AddSymbols(rootCommand);

void addOptions(Command command)
void AddSymbols(CliCommand command)
{
command.Add(quietOption);
command.Add(verboseOption);
command.Add(noHotReloadOption);
command.Add(nonInteractiveOption);
command.Add(longProjectOption);
command.Add(shortProjectOption);
command.Options.Add(quietOption);
command.Options.Add(verboseOption);
command.Options.Add(noHotReloadOption);
command.Options.Add(nonInteractiveOption);
command.Options.Add(longProjectOption);
command.Options.Add(shortProjectOption);

if (command == runCommand)
{
command.Add(launchProfileRunOption);
command.Add(noLaunchProfileRunOption);
command.Options.Add(launchProfileRunOption);
command.Options.Add(noLaunchProfileRunOption);
}
else
{
command.Add(launchProfileWatchOption);
command.Add(noLaunchProfileWatchOption);
command.Options.Add(launchProfileWatchOption);
command.Options.Add(noLaunchProfileWatchOption);
}

command.Add(targetFrameworkOption);
command.Add(propertyOption);
command.Options.Add(targetFrameworkOption);
command.Options.Add(propertyOption);

command.Add(listOption);
command.Options.Add(listOption);

if (command == runCommand)
{
command.Add(remainingRunArgs);
command.Arguments.Add(remainingRunArgs);
}
else
{
command.Add(runCommand);
command.Add(remainingWatchArgs);
command.Subcommands.Add(runCommand);
command.Arguments.Add(remainingWatchArgs);
}
};

CommandLineOptions? options = null;

runCommand.SetHandler(context =>
runCommand.SetAction(parseResult =>
{
RootHandler(context, new()
RootHandler(parseResult, new()
{
LaunchProfileName = context.ParseResult.GetValue(launchProfileRunOption),
NoLaunchProfile = context.ParseResult.GetValue(noLaunchProfileRunOption),
RemainingArguments = context.ParseResult.GetValue(remainingRunArgs),
LaunchProfileName = parseResult.GetValue(launchProfileRunOption),
NoLaunchProfile = parseResult.GetValue(noLaunchProfileRunOption),
RemainingArguments = parseResult.GetValue(remainingRunArgs) ?? Array.Empty<string>(),
});
});

rootCommand.SetHandler(context => RootHandler(context, runOptions: null));
rootCommand.SetAction(parseResult => RootHandler(parseResult, runOptions: null));

void RootHandler(InvocationContext context, RunCommandLineOptions? runOptions)
void RootHandler(ParseResult parseResults, RunCommandLineOptions? runOptions)
{
var parseResults = context.ParseResult;
var projectValue = parseResults.GetValue(longProjectOption);
if (string.IsNullOrEmpty(projectValue))
{
Expand All @@ -207,12 +224,17 @@ void RootHandler(InvocationContext context, RunCommandLineOptions? runOptions)
TargetFramework = parseResults.GetValue(targetFrameworkOption),
BuildProperties = parseResults.GetValue(propertyOption)?
.Select(p => (p[..p.IndexOf('=')].Trim(), p[(p.IndexOf('=') + 1)..])).ToArray(),
RemainingArguments = parseResults.GetValue(remainingWatchArgs),
RemainingArguments = parseResults.GetValue(remainingWatchArgs) ?? Array.Empty<string>(),
RunOptions = runOptions,
};
}

errorCode = rootCommand.Invoke(args, console);
errorCode = new CliConfiguration(rootCommand)
{
Output = output ?? Console.Out,
Error = error ?? Console.Error
}.Invoke(args);

return options;
}

Expand Down
Loading