From f078581947f6f1f3c36320181e91d934c8e5deaf Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Mon, 21 Apr 2025 12:49:02 +0300 Subject: [PATCH] Print arguments that were not consumed Fixes #88 --- DepotDownloader/Program.cs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/DepotDownloader/Program.cs b/DepotDownloader/Program.cs index 89130b19..475c20ba 100644 --- a/DepotDownloader/Program.cs +++ b/DepotDownloader/Program.cs @@ -17,6 +17,8 @@ namespace DepotDownloader { class Program { + private static bool[] consumedArgs; + static async Task Main(string[] args) { if (args.Length == 0) @@ -47,6 +49,8 @@ namespace DepotDownloader return 0; } + consumedArgs = new bool[args.Length]; + if (HasParameter(args, "-debug")) { PrintVersion(true); @@ -168,6 +172,8 @@ namespace DepotDownloader { #region Pubfile Downloading + PrintUnconsumedArgs(args); + if (InitializeSteam(username, password)) { try @@ -203,6 +209,8 @@ namespace DepotDownloader { #region UGC Downloading + PrintUnconsumedArgs(args); + if (InitializeSteam(username, password)) { try @@ -293,6 +301,8 @@ namespace DepotDownloader depotManifestIds.AddRange(depotIdList.Select(depotId => (depotId, ContentDownloader.INVALID_MANIFEST_ID))); } + PrintUnconsumedArgs(args); + if (InitializeSteam(username, password)) { try @@ -379,7 +389,10 @@ namespace DepotDownloader for (var x = 0; x < args.Length; ++x) { if (args[x].Equals(param, StringComparison.OrdinalIgnoreCase)) + { + consumedArgs[x] = true; return x; + } } return -1; @@ -402,6 +415,7 @@ namespace DepotDownloader var converter = TypeDescriptor.GetConverter(typeof(T)); if (converter != null) { + consumedArgs[index + 1] = true; return (T)converter.ConvertFromString(strParam); } @@ -427,6 +441,7 @@ namespace DepotDownloader var converter = TypeDescriptor.GetConverter(typeof(T)); if (converter != null) { + consumedArgs[index] = true; list.Add((T)converter.ConvertFromString(strParam)); } @@ -436,6 +451,26 @@ namespace DepotDownloader return list; } + static void PrintUnconsumedArgs(string[] args) + { + var printError = false; + + for (var index = 0; index < consumedArgs.Length; index++) + { + if (!consumedArgs[index]) + { + printError = true; + Console.Error.WriteLine($"Argument #{index + 1} {args[index]} was not used."); + } + } + + if (printError) + { + Console.Error.WriteLine("Make sure you specified the arguments correctly. Check --help for correct arguments."); + Console.Error.WriteLine(); + } + } + static void PrintUsage() { // Do not use tabs to align parameters here because tab size may differ