From 8d89d630531aa9e664c6a1bfcdb7f82064195525 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Mon, 22 May 2017 18:07:12 -0400 Subject: [PATCH] add --passkey, -p argument, fix #6 --- Program.cs | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/Program.cs b/Program.cs index 01e350f..4b9c6ea 100644 --- a/Program.cs +++ b/Program.cs @@ -28,12 +28,14 @@ namespace SteamGuard { string action = ""; string user = ""; + string passkey = ""; // Parse cli arguments for (int i = 0; i < args.Length; i++) { if (args[i].StartsWith("-")) { + // TODO: there's gotta be some framework or tool or something for this if (args[i] == "-v" || args[i] == "--verbose") { Verbose = true; @@ -51,6 +53,19 @@ namespace SteamGuard return; } } + else if (args[i] == "-p" || args[i] == "--passkey") + { + i++; + if (i < args.Length) + { + passkey = args[i]; + } + else + { + Console.WriteLine($"Expected encryption passkey after {args[i-1]}"); + return; + } + } else if (args[i] == "--help" || args[i] == "-h") { ShowHelp(); @@ -122,6 +137,7 @@ namespace SteamGuard { Console.WriteLine($"Action: {action}"); Console.WriteLine($"User: {user}"); + Console.WriteLine($"Passkey: {passkey}"); Console.WriteLine($"maFiles path: {SteamGuardPath}"); } @@ -129,22 +145,22 @@ namespace SteamGuard switch (action) { case "generate-code": - GenerateCode(user); + GenerateCode(user, passkey); break; case "encrypt": // Can also be used to change passkey - Console.WriteLine(Encrypt()); + Console.WriteLine(Encrypt(passkey)); break; case "decrypt": - Console.WriteLine(Decrypt()); + Console.WriteLine(Decrypt(passkey)); break; case "setup": - Setup(user); + Setup(user, passkey); break; case "trade": - Trade(user); + Trade(user, passkey); break; case "accept-all": - AcceptAllTrades(user); + AcceptAllTrades(user, passkey); break; default: Console.WriteLine("error: Unknown action: {0}", action);