diff --git a/DepotDownloader/Program.cs b/DepotDownloader/Program.cs index 4c08ee50..0879e8f7 100644 --- a/DepotDownloader/Program.cs +++ b/DepotDownloader/Program.cs @@ -24,20 +24,20 @@ public static Task Main(string[] args) { new Option("--debug") { IsHidden = true }, - new Option("--app", "The AppID to download") { IsRequired = true, ArgumentHelpName = "id" }, + new Option("--app", "The AppID to download") { IsRequired = true, ArgumentHelpName = "id", Name = "AppId" }, - new Option("--depot", "The DepotID to download") { ArgumentHelpName = "id" }, - new Option("--manifest", "Manifest id of content to download (requires --depot, default: current for branch)"), + new Option("--depot", "The DepotID to download") { ArgumentHelpName = "id", Name = "Depots" }, + new Option("--manifest", "Manifest id of content to download (requires --depot, default: current for branch)") { ArgumentHelpName = "id", Name = "Manifests" }, - new Option("--ugc", "The UGC ID to download"), - new Option("--pubfile", "The PublishedFileId to download (will automatically resolve to UGC id)"), + new Option("--ugc", "The UGC ID to download") { ArgumentHelpName = "id" }, + new Option("--pubfile", "The PublishedFileId to download (will automatically resolve to UGC id)") { ArgumentHelpName = "id", Name = "PublishedFileIds" }, new Option(new[] { "--branch", "--beta" }, "Download from specified branch if available"), new Option(new[] { "--branch-password", "--betapassword" }, "Branch password if applicable"), - new Option("--os", () => new[] { Util.GetSteamOS() }, "The operating system for which to download the game").FromAmong("all", "windows", "macos", "linux"), - new Option("--arch", () => new[] { Util.GetSteamArch() }, "The architecture for which to download the game").FromAmong("64", "32"), - new Option("--language", () => new[] { "english" }, "The language for which to download the game"), + new Option("--os", () => new[] { Util.GetSteamOS() }, "The operating system for which to download the game") { Name = "OperatingSystems" }.FromAmong("all", "windows", "macos", "linux"), + new Option("--arch", () => new[] { Util.GetSteamArch() }, "The architecture for which to download the game") { Name = "Architectures" }.FromAmong("64", "32"), + new Option("--language", () => new[] { "english" }, "The language for which to download the game") { ArgumentHelpName = "language", Name = "Languages" }, new Option("--lowviolence", "Download low violence depots"), new Option("--username", "The username of the account to login to for restricted content"), @@ -46,7 +46,7 @@ public static Task Main(string[] args) new Option(new[] { "--directory", "--dir" }, "The directory in which to place downloaded files"), new Option("--filelist", "A list of files to download (from the manifest). Prefix file path with 'regex:' if you want to match with regex").ExistingOnly(), - new Option(new[] { "--validate", "--verify-all" }, "Include checksum verification of files already downloaded"), + new Option(new[] { "--validate", "--verify-all" }, "Include checksum verification of files already downloaded") { Name = "Validate" }, new Option("--manifest-only", "Downloads a human readable manifest for any depots that would be downloaded"), new Option("--cellid", "The overridden CellID of the content server to download from"), @@ -59,7 +59,19 @@ public static Task Main(string[] args) return new CommandLineBuilder(rootCommand) .UseDefaults() - .UseHelp(help => help.HelpBuilder.CustomizeLayout(GetHelpLayout)) + .UseHelp(help => + { + // Workaround https://github.com/dotnet/command-line-api/issues/1550 + foreach (var option in rootCommand.Options) + { + if (option.HasAlias(option.Name)) + { + help.HelpBuilder.CustomizeSymbol(option, context => HelpBuilder.Default.GetIdentifierSymbolUsageLabel(option, context)[(option.Name.Length + 2)..]); + } + } + + help.HelpBuilder.CustomizeLayout(GetHelpLayout); + }) .Build().InvokeAsync(args); } @@ -85,66 +97,31 @@ private static IEnumerable GetHelpLayout(HelpContext _) yield return HelpBuilder.Default.AdditionalArgumentsSection(); } - public class InputModel - { - public InputModel(bool debug, uint app, uint[] depot, ulong[] manifest, ulong? ugc, ulong[] pubfile, string? branch, string? branchPassword, string[] os, string[] arch, string[] language, bool lowViolence, string? username, string? password, bool rememberPassword, DirectoryInfo? directory, FileInfo? fileList, bool validate, bool manifestOnly, int? cellId, int maxServers, int maxDownloads, uint? loginId) - { - Debug = debug; - AppId = app; - Depots = depot; - Manifests = manifest; - UgcId = ugc; - PublishedFileIds = pubfile; - Branch = branch; - BranchPassword = branchPassword; - OperatingSystems = os; - Architectures = arch; - Languages = language; - LowViolence = lowViolence; - Username = username; - Password = password; - RememberPassword = rememberPassword; - Directory = directory; - FileList = fileList; - Validate = validate; - ManifestOnly = manifestOnly; - CellId = cellId; - MaxServers = maxServers; - MaxDownloads = maxDownloads; - LoginId = loginId; - } - public bool Debug { get; } - - public uint AppId { get; } - - public uint[] Depots { get; } - public ulong[] Manifests { get; } - - public ulong? UgcId { get; } - public ulong[] PublishedFileIds { get; } - - public string? Branch { get; } - public string? BranchPassword { get; } - - public string[] OperatingSystems { get; } - public string[] Architectures { get; } - public string[] Languages { get; } - public bool LowViolence { get; } - - public string? Username { get; } - public string? Password { get; } - public bool RememberPassword { get; } - - public DirectoryInfo? Directory { get; } - public FileInfo? FileList { get; } - public bool Validate { get; } - public bool ManifestOnly { get; } - - public int? CellId { get; } - public int MaxServers { get; } - public int MaxDownloads { get; } - public uint? LoginId { get; } - } + public record InputModel( + bool Debug, + uint AppId, + uint[] Depots, + ulong[] Manifests, + ulong? UgcId, + ulong[] PublishedFileIds, + string? Branch, + string? BranchPassword, + string[] OperatingSystems, + string[] Architectures, + string[] Languages, + bool LowViolence, + string? Username, + string? Password, + bool RememberPassword, + DirectoryInfo? Directory, + FileInfo? FileList, + bool Validate, + bool ManifestOnly, + int? CellId, + int MaxServers, + int MaxDownloads, + uint? LoginId + ); public static async Task DownloadAsync(InputModel input) {