From 8117d8f6c20249930e44775c38a8bd836d00b10e Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Wed, 28 Aug 2024 12:59:28 +0300 Subject: [PATCH] Add -V/--version Fixes #531 --- DepotDownloader/Program.cs | 26 +++++++++++++++++++++++--- README.md | 2 +- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/DepotDownloader/Program.cs b/DepotDownloader/Program.cs index af90cdfba..b44b79c2f 100644 --- a/DepotDownloader/Program.cs +++ b/DepotDownloader/Program.cs @@ -20,6 +20,7 @@ static async Task Main(string[] args) { if (args.Length == 0) { + PrintVersion(); PrintUsage(); if (OperatingSystem.IsWindowsVersionAtLeast(5, 0)) @@ -38,8 +39,17 @@ static async Task Main(string[] args) #region Common Options + // Not using HasParameter because it is case insensitive + if (args.Length == 1 && (args[0] == "-V" || args[0] == "--version")) + { + PrintVersion(true); + return 0; + } + if (HasParameter(args, "-debug")) { + PrintVersion(true); + DebugLog.Enabled = true; DebugLog.AddListener((category, message) => { @@ -47,9 +57,6 @@ static async Task Main(string[] args) }); var httpEventListener = new HttpDiagnosticEventListener(); - - DebugLog.WriteLine("DepotDownloader", "Version: {0}", Assembly.GetExecutingAssembly().GetName().Version); - DebugLog.WriteLine("DepotDownloader", "Runtime: {0}", RuntimeInformation.FrameworkDescription); } var username = GetParameter(args, "-username") ?? GetParameter(args, "-user"); @@ -417,5 +424,18 @@ static void PrintUsage() Console.WriteLine(" -max-downloads <#> - maximum number of chunks to download concurrently. (default: 8)."); Console.WriteLine(" -loginid <#> - a unique 32-bit integer Steam LogonID in decimal, required if running multiple instances of DepotDownloader concurrently."); } + + static void PrintVersion(bool printExtra = false) + { + var version = typeof(Program).Assembly.GetCustomAttribute().InformationalVersion; + Console.WriteLine($"DepotDownloader v{version}"); + + if (!printExtra) + { + return; + } + + Console.WriteLine($"Runtime: {RuntimeInformation.FrameworkDescription} on {RuntimeInformation.OSDescription}"); + } } } diff --git a/README.md b/README.md index a26425936..67de48b22 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ Parameter | Description `-max-servers <#>` | maximum number of content servers to use. (default: 20). `-max-downloads <#>` | maximum number of chunks to download concurrently. (default: 8). `-loginid <#>` | a unique 32-bit integer Steam LogonID in decimal, required if running multiple instances of DepotDownloader concurrently. - +`-V` or `--version` | print version and runtime ## Frequently Asked Questions