Skip to content

System.CommandLine update for src/SourceBuild #48520

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

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 8 additions & 8 deletions src/SourceBuild/content/eng/tools/BinaryToolKit/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ namespace BinaryToolKit;

public class Program
{
public static readonly CliArgument<string> TargetDirectory = new("target-directory")
public static readonly Argument<string> TargetDirectory = new("target-directory")
{
Description = "The directory to run the binary tooling on.",
Arity = ArgumentArity.ExactlyOne
};

public static readonly CliOption<string> OutputReportDirectory = new("--output-directory", "-o")
public static readonly Option<string> OutputReportDirectory = new("--output-directory", "-o")
{
Description = "The directory to output the report to.",
Arity = ArgumentArity.ZeroOrOne,
DefaultValueFactory = _ => Path.Combine(Directory.GetCurrentDirectory(), "binary-report")
};

public static readonly CliOption<LogLevel> Level = new("--log-level", "-l")
public static readonly Option<LogLevel> Level = new("--log-level", "-l")
{
Description = "The log level to run the tool in.",
Arity = ArgumentArity.ZeroOrOne,
DefaultValueFactory = _ => LogLevel.Information,
Recursive = true
};

public static readonly CliOption<string> AllowedBinariesFile = new("--allowed-binaries-file", "-ab")
public static readonly Option<string> AllowedBinariesFile = new("--allowed-binaries-file", "-ab")
{
Description = "The file containing the list of allowed binaries that are ignored for cleaning or validating.\n",
Arity = ArgumentArity.ZeroOrOne
Expand All @@ -43,7 +43,7 @@ public static async Task<int> Main(string[] args)
var cleanCommand = CreateCommand("clean", "Clean the binaries in the target directory.");
var validateCommand = CreateCommand("validate", "Detect new binaries in the target directory.");

var rootCommand = new CliRootCommand("Tool for detecting, validating, and cleaning binaries in the target directory.")
var rootCommand = new RootCommand("Tool for detecting, validating, and cleaning binaries in the target directory.")
{
Level,
cleanCommand,
Expand All @@ -58,17 +58,17 @@ public static async Task<int> Main(string[] args)
return ExitCode;
}

private static CliCommand CreateCommand(string name, string description)
private static Command CreateCommand(string name, string description)
{
return new CliCommand(name, description)
return new Command(name, description)
{
TargetDirectory,
OutputReportDirectory,
AllowedBinariesFile
};
}

private static void SetCommandAction(CliCommand command, Modes mode)
private static void SetCommandAction(Command command, Modes mode)
{
command.SetAction(async (result, CancellationToken) =>
{
Expand Down
16 changes: 8 additions & 8 deletions src/SourceBuild/content/eng/tools/BuildComparer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,43 @@ public class Program
/// <returns>Return code indicating success (0) or failure (non-zero).</returns>
static int Main(string[] args)
{
var vmrManifestPathArgument = new CliOption<string>("-vmrManifestPath")
var vmrManifestPathArgument = new Option<string>("-vmrManifestPath")
{
Description = "Path to the manifest file",
Required = true
};
var vmrAssetBasePathArgument = new CliOption<string>("-vmrAssetBasePath")
var vmrAssetBasePathArgument = new Option<string>("-vmrAssetBasePath")
{
Description = "Path to the manifest file",
Copy link
Preview

Copilot AI Apr 16, 2025

Choose a reason for hiding this comment

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

The description for vmrAssetBasePathArgument reads 'Path to the manifest file', which appears to be a copy-paste error. Please update it to accurately describe the asset base path.

Suggested change
Description = "Path to the manifest file",
Description = "Base path for VMR assets",

Copilot uses AI. Check for mistakes.

Required = true
};
var msftAssetBasePathArgument = new CliOption<string>("-msftAssetBasePath")
var msftAssetBasePathArgument = new Option<string>("-msftAssetBasePath")
{
Description = "Path to the asset base path",
Required = true
};
var issuesReportArgument = new CliOption<string>("-issuesReport")
var issuesReportArgument = new Option<string>("-issuesReport")
{
Description = "Path to output xml file for non-baselined issues.",
Required = true
};
var noIssuesReportArgument = new CliOption<string>("-noIssuesReport")
var noIssuesReportArgument = new Option<string>("-noIssuesReport")
{
Description = "Path to output xml file for baselined issues and assets without issues.",
Required = true
};
var parallelismArgument = new CliOption<int>("-parallel")
var parallelismArgument = new Option<int>("-parallel")
{
Description = "Amount of parallelism used while analyzing the builds.",
DefaultValueFactory = _ => 8,
Required = true
};
var baselineArgument = new CliOption<string>("-baseline")
var baselineArgument = new Option<string>("-baseline")
{
Description = "Path to the baseline build manifest.",
Required = true
};
var rootCommand = new CliRootCommand(description: "Tool for comparing Microsoft builds with VMR builds.")
var rootCommand = new RootCommand(description: "Tool for comparing Microsoft builds with VMR builds.")
{
vmrManifestPathArgument,
vmrAssetBasePathArgument,
Expand Down
24 changes: 12 additions & 12 deletions src/SourceBuild/content/eng/tools/CreateBaselineUpdatePR/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,52 @@ namespace CreateBaselineUpdatePR;

public class Program
{
public static readonly CliArgument<string> Repo = new("repo")
public static readonly Argument<string> Repo = new("repo")
{
Description = "The GitHub repository to create the PR in. Should be in the form '<owner>/<repo-name>'",
Arity = ArgumentArity.ExactlyOne
};

public static readonly CliArgument<string> OriginalFilesDirectory = new("original-files-directory")
public static readonly Argument<string> OriginalFilesDirectory = new("original-files-directory")
{
Description = "The directory where the original test files are located. Should be relative to the repo",
Arity = ArgumentArity.ExactlyOne
};

public static readonly CliArgument<string> UpdatedFilesDirectory = new("updated-files-directory")
public static readonly Argument<string> UpdatedFilesDirectory = new("updated-files-directory")
{
Description = "The directory containing the updated test files published by the associated test. Should be absolute or relative to the working directory of the tool.",
Arity = ArgumentArity.ExactlyOne
};

public static readonly CliArgument<int> BuildId = new("build-id")
public static readonly Argument<int> BuildId = new("build-id")
{
Description = "The id of the build that published the updated test files.",
Arity = ArgumentArity.ExactlyOne
};

public static readonly CliOption<string> Title = new("--title", "-t")
public static readonly Option<string> Title = new("--title", "-t")
{
Description = "The title of the PR.",
Arity = ArgumentArity.ZeroOrOne,
DefaultValueFactory = _ => "Update Test Baselines and Exclusions"
};

public static readonly CliOption<string> Branch = new("--branch", "-b")
public static readonly Option<string> Branch = new("--branch", "-b")
{
Description = "The target branch of the PR.",
Arity = ArgumentArity.ZeroOrOne,
DefaultValueFactory = _ => "main"
};

public static readonly CliOption<string> GitHubToken = new("--github-token", "-g")
public static readonly Option<string> GitHubToken = new("--github-token", "-g")
{
Description = "The GitHub token to use to create the PR.",
Arity = ArgumentArity.ZeroOrOne,
DefaultValueFactory = _ => Environment.GetEnvironmentVariable("GH_TOKEN") ?? throw new ArgumentException("GitHub token not provided.")
};

public static readonly CliOption<LogLevel> Level = new("--log-level", "-l")
public static readonly Option<LogLevel> Level = new("--log-level", "-l")
{
Description = "The log level to run the tool in.",
Arity = ArgumentArity.ZeroOrOne,
Expand All @@ -69,7 +69,7 @@ public static async Task<int> Main(string[] args)
var sdkDiffTestsCommand = CreateCommand("sdk", "Creates a PR that updates baselines and exclusion files published by the sdk diff tests.");
var licenseScanTestsCommand = CreateCommand("license", "Creates a PR that updates baselines and exclusion files published by the license scan tests.");

var rootCommand = new CliRootCommand("Tool for creating PRs that update baselines and exclusion files.")
var rootCommand = new RootCommand("Tool for creating PRs that update baselines and exclusion files.")
{
Level,
sdkDiffTestsCommand,
Expand All @@ -84,9 +84,9 @@ public static async Task<int> Main(string[] args)
return ExitCode;
}

private static CliCommand CreateCommand(string name, string description)
private static Command CreateCommand(string name, string description)
{
return new CliCommand(name, description)
return new Command(name, description)
{
Repo,
OriginalFilesDirectory,
Expand All @@ -98,7 +98,7 @@ private static CliCommand CreateCommand(string name, string description)
};
}

private static void SetCommandAction(CliCommand command, Pipelines pipeline)
private static void SetCommandAction(Command command, Pipelines pipeline)
{
command.SetAction(async (result, CancellationToken) =>
{
Expand Down
Loading