Skip to content

Commit

Permalink
feat(cli): add --steamid parameter in xlsx command
Browse files Browse the repository at this point in the history
  • Loading branch information
akiver committed Jul 15, 2022
1 parent ea5e273 commit 2c50ee3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
22 changes: 22 additions & 0 deletions CLI/ExportCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal abstract class ExportCommand : BaseCommand
protected readonly List<string> _demoPaths;
protected string _outputFolderPath;
protected bool _forceAnalyze = false;
protected long _focusSteamId = 0;
protected List<string> _availableSources = new List<string>();

public ExportCommand(string commandName, string description) : base(commandName, description)
Expand Down Expand Up @@ -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))
{
Expand Down
7 changes: 4 additions & 3 deletions CLI/XlsxCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:");
Expand Down Expand Up @@ -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}"),
Expand Down

0 comments on commit 2c50ee3

Please sign in to comment.