From 13072ecc79970f3e379f968290f867869f1ff7b5 Mon Sep 17 00:00:00 2001 From: fiso64 Date: Sun, 22 Dec 2024 19:56:41 +0100 Subject: [PATCH] add --version --- slsk-batchdl/Help.cs | 15 +++++++++++++-- slsk-batchdl/Program.cs | 2 +- slsk-batchdl/slsk-batchdl.csproj | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/slsk-batchdl/Help.cs b/slsk-batchdl/Help.cs index 127d68d..e159bb3 100644 --- a/slsk-batchdl/Help.cs +++ b/slsk-batchdl/Help.cs @@ -181,9 +181,10 @@ public static class Help --relax-filtering Slightly relax file filtering in aggregate mode to include more results - Help + Other -h, --help [option] [all|input|download-modes|search|name-format| file-conditions|config|shortcuts] + --version Print program version and exit Notes Acronyms of two- and --three-word-flags are also accepted, e.g. --twf. If the option @@ -523,7 +524,12 @@ public static class Help Console.WriteLine(text); } - public static void PrintHelpAndExitIfNeeded(string[] args) + public static void PrintVersion() + { + Console.WriteLine(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version); + } + + public static void PrintAndExitIfNeeded(string[] args) { int helpIdx = Array.FindLastIndex(args, x => x == "--help" || x == "-h"); if (args.Length == 0 || helpIdx >= 0) @@ -531,6 +537,11 @@ public static class Help PrintHelp(helpIdx + 1 < args.Length ? args[helpIdx + 1] : null); Environment.Exit(0); } + else if (args.Contains("--version")) + { + PrintVersion(); + Environment.Exit(0); + } } } diff --git a/slsk-batchdl/Program.cs b/slsk-batchdl/Program.cs index 1ffcb62..5a95f10 100644 --- a/slsk-batchdl/Program.cs +++ b/slsk-batchdl/Program.cs @@ -37,7 +37,7 @@ static partial class Program { Console.ResetColor(); Console.OutputEncoding = System.Text.Encoding.UTF8; - Help.PrintHelpAndExitIfNeeded(args); + Help.PrintAndExitIfNeeded(args); var config = new Config(args); diff --git a/slsk-batchdl/slsk-batchdl.csproj b/slsk-batchdl/slsk-batchdl.csproj index a5946e6..284773f 100644 --- a/slsk-batchdl/slsk-batchdl.csproj +++ b/slsk-batchdl/slsk-batchdl.csproj @@ -6,7 +6,7 @@ enable enable sldl - 2.4.0 + 2.4.1