From fb54ff649ce2d53f839d6ca72336b71376a6ba72 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Wed, 16 Apr 2025 19:00:41 +0200 Subject: [PATCH] System.CommandLine update for src/SourceBuild --- .../eng/tools/BinaryToolKit/Program.cs | 16 ++++++------- .../eng/tools/BuildComparer/Program.cs | 16 ++++++------- .../tools/CreateBaselineUpdatePR/Program.cs | 24 +++++++++---------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/SourceBuild/content/eng/tools/BinaryToolKit/Program.cs b/src/SourceBuild/content/eng/tools/BinaryToolKit/Program.cs index 5feb90aad74a..768e76e36d0a 100644 --- a/src/SourceBuild/content/eng/tools/BinaryToolKit/Program.cs +++ b/src/SourceBuild/content/eng/tools/BinaryToolKit/Program.cs @@ -9,20 +9,20 @@ namespace BinaryToolKit; public class Program { - public static readonly CliArgument TargetDirectory = new("target-directory") + public static readonly Argument TargetDirectory = new("target-directory") { Description = "The directory to run the binary tooling on.", Arity = ArgumentArity.ExactlyOne }; - public static readonly CliOption OutputReportDirectory = new("--output-directory", "-o") + public static readonly Option 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 Level = new("--log-level", "-l") + public static readonly Option Level = new("--log-level", "-l") { Description = "The log level to run the tool in.", Arity = ArgumentArity.ZeroOrOne, @@ -30,7 +30,7 @@ public class Program Recursive = true }; - public static readonly CliOption AllowedBinariesFile = new("--allowed-binaries-file", "-ab") + public static readonly Option 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 @@ -43,7 +43,7 @@ public static async Task 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, @@ -58,9 +58,9 @@ public static async Task 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, @@ -68,7 +68,7 @@ private static CliCommand CreateCommand(string name, string description) }; } - private static void SetCommandAction(CliCommand command, Modes mode) + private static void SetCommandAction(Command command, Modes mode) { command.SetAction(async (result, CancellationToken) => { diff --git a/src/SourceBuild/content/eng/tools/BuildComparer/Program.cs b/src/SourceBuild/content/eng/tools/BuildComparer/Program.cs index 4c5f938173e8..2e0528abc8f0 100644 --- a/src/SourceBuild/content/eng/tools/BuildComparer/Program.cs +++ b/src/SourceBuild/content/eng/tools/BuildComparer/Program.cs @@ -24,43 +24,43 @@ public class Program /// Return code indicating success (0) or failure (non-zero). static int Main(string[] args) { - var vmrManifestPathArgument = new CliOption("-vmrManifestPath") + var vmrManifestPathArgument = new Option("-vmrManifestPath") { Description = "Path to the manifest file", Required = true }; - var vmrAssetBasePathArgument = new CliOption("-vmrAssetBasePath") + var vmrAssetBasePathArgument = new Option("-vmrAssetBasePath") { Description = "Path to the manifest file", Required = true }; - var msftAssetBasePathArgument = new CliOption("-msftAssetBasePath") + var msftAssetBasePathArgument = new Option("-msftAssetBasePath") { Description = "Path to the asset base path", Required = true }; - var issuesReportArgument = new CliOption("-issuesReport") + var issuesReportArgument = new Option("-issuesReport") { Description = "Path to output xml file for non-baselined issues.", Required = true }; - var noIssuesReportArgument = new CliOption("-noIssuesReport") + var noIssuesReportArgument = new Option("-noIssuesReport") { Description = "Path to output xml file for baselined issues and assets without issues.", Required = true }; - var parallelismArgument = new CliOption("-parallel") + var parallelismArgument = new Option("-parallel") { Description = "Amount of parallelism used while analyzing the builds.", DefaultValueFactory = _ => 8, Required = true }; - var baselineArgument = new CliOption("-baseline") + var baselineArgument = new Option("-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, diff --git a/src/SourceBuild/content/eng/tools/CreateBaselineUpdatePR/Program.cs b/src/SourceBuild/content/eng/tools/CreateBaselineUpdatePR/Program.cs index 641f3b20df18..bdf940673386 100644 --- a/src/SourceBuild/content/eng/tools/CreateBaselineUpdatePR/Program.cs +++ b/src/SourceBuild/content/eng/tools/CreateBaselineUpdatePR/Program.cs @@ -9,52 +9,52 @@ namespace CreateBaselineUpdatePR; public class Program { - public static readonly CliArgument Repo = new("repo") + public static readonly Argument Repo = new("repo") { Description = "The GitHub repository to create the PR in. Should be in the form '/'", Arity = ArgumentArity.ExactlyOne }; - public static readonly CliArgument OriginalFilesDirectory = new("original-files-directory") + public static readonly Argument 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 UpdatedFilesDirectory = new("updated-files-directory") + public static readonly Argument 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 BuildId = new("build-id") + public static readonly Argument BuildId = new("build-id") { Description = "The id of the build that published the updated test files.", Arity = ArgumentArity.ExactlyOne }; - public static readonly CliOption Title = new("--title", "-t") + public static readonly Option Title = new("--title", "-t") { Description = "The title of the PR.", Arity = ArgumentArity.ZeroOrOne, DefaultValueFactory = _ => "Update Test Baselines and Exclusions" }; - public static readonly CliOption Branch = new("--branch", "-b") + public static readonly Option Branch = new("--branch", "-b") { Description = "The target branch of the PR.", Arity = ArgumentArity.ZeroOrOne, DefaultValueFactory = _ => "main" }; - public static readonly CliOption GitHubToken = new("--github-token", "-g") + public static readonly Option 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 Level = new("--log-level", "-l") + public static readonly Option Level = new("--log-level", "-l") { Description = "The log level to run the tool in.", Arity = ArgumentArity.ZeroOrOne, @@ -69,7 +69,7 @@ public static async Task 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, @@ -84,9 +84,9 @@ public static async Task 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, @@ -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) => {