From 2c50ee34dedbf9405c9a740e10d8d25ec52f252b Mon Sep 17 00:00:00 2001 From: AkiVer Date: Fri, 15 Jul 2022 22:52:48 +0200 Subject: [PATCH] feat(cli): add --steamid parameter in xlsx command --- CLI/ExportCommand.cs | 22 ++++++++++++++++++++++ CLI/XlsxCommand.cs | 7 ++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CLI/ExportCommand.cs b/CLI/ExportCommand.cs index d89efa390..51fe17770 100644 --- a/CLI/ExportCommand.cs +++ b/CLI/ExportCommand.cs @@ -12,6 +12,7 @@ internal abstract class ExportCommand : BaseCommand protected readonly List _demoPaths; protected string _outputFolderPath; protected bool _forceAnalyze = false; + protected long _focusSteamId = 0; protected List _availableSources = new List(); public ExportCommand(string commandName, string description) : base(commandName, description) @@ -85,6 +86,27 @@ protected void ParseArgs(string[] args, string[] allowedOptions) case "--force-analyze": _forceAnalyze = true; break; + case "--steamid": + if (args.Length > index + 1) + { + index += 1; + bool success = long.TryParse(args[index], out long steamId); + if (success) + { + _focusSteamId = steamId; + } + else + { + Console.WriteLine(@"Invalid SteamID"); + Environment.Exit(1); + } + } + else + { + Console.WriteLine(@"Missing --steamid argument value"); + Environment.Exit(1); + } + break; default: if (!allowedOptions.Contains(arg)) { diff --git a/CLI/XlsxCommand.cs b/CLI/XlsxCommand.cs index e1358a42b..1259ab9b6 100644 --- a/CLI/XlsxCommand.cs +++ b/CLI/XlsxCommand.cs @@ -21,12 +21,13 @@ public override void PrintHelp() { Console.WriteLine(GetDescription()); Console.WriteLine(@""); - Console.WriteLine($@"Usage: {Program.ExeName} {COMMAND_NAME} demoPaths... [--output] [--source] [--single] [--force-analyze]"); + Console.WriteLine($@"Usage: {Program.ExeName} {COMMAND_NAME} demoPaths... [--output] [--source] [--single] [--steamid] [--force-analyze]"); Console.WriteLine(@""); Console.WriteLine(@"Demos path can be either .dem files location or a directory. It can be relative or absolute."); Console.WriteLine(@"The --output argument specify the directory where output files will be saved."); Console.WriteLine($@"The --source argument force the analysis logic of the demo analyzer. Available values: [{string.Join(",", _availableSources)}]"); - Console.WriteLine($@"The --single argument generates a single XLSX file instead of one per demo."); + Console.WriteLine(@"The --single argument generates a single XLSX file instead of one per demo."); + Console.WriteLine(@"The --steamid argument makes data in some sheets focusing on the player with the given SteamID (works with --single only)."); Console.WriteLine(@"The --force-analyze argument force demos analyzes (ignore cached data)."); Console.WriteLine(@""); Console.WriteLine(@"Examples:"); @@ -100,7 +101,7 @@ private async Task ProcessSingleFileExport() { FileName = fileName, DemoPaths = _demoPaths, - FocusSteamId = 0, // TODO --steamid parameter + FocusSteamId = _focusSteamId, Source = _source, OnProcessingDemo = (demoPath, demoNumber, totalDemoCount) => Console.WriteLine($@"Retrieving demo {demoNumber}/{totalDemoCount} {demoPath}"), OnDemoNotFound = demoPath => Console.WriteLine($@"The demo doesn't exists: {demoPath}"),