added action based system where the program will perform different actions based on cli arguments.

This commit is contained in:
Carson McManus 2016-08-22 19:16:43 -04:00
parent 725562ffcd
commit a4f164a128

View file

@ -22,6 +22,8 @@ public static class Program
[STAThread]
public static void Main(string[] args)
{
string action = "generate-code";
string user = "";
// Parse cli arguments
@ -36,6 +38,24 @@ public static class Program
return;
}
Verbose = args.Contains("-v") || args.Contains("--verbose");
// Actions
if (args.Contains("--generate-code"))
{
action = "generate-code";
}
else if (args.Contains("--encrypt"))
{
action = "encrypt";
}
else if (args.Contains("--decrypt"))
{
action = "decrypt";
}
else if (args.Contains("--setup"))
{
action = "setup";
}
// Misc
if (args.Contains("--user") || args.Contains("-u"))
{
int u = Array.IndexOf(args, "--user");
@ -72,7 +92,26 @@ public static class Program
}
if (Verbose) Console.WriteLine("maFiles path: {0}", SteamGuardPath);
// Generate the code
// Perform desired action
switch (action)
{
case "generate-code":
GenerateCode(user);
break;
case "encrypt":
break;
case "decrypt":
break;
case "setup":
break;
default:
Console.WriteLine("error: Unknown action: {0}", action);
return;
}
}
static void GenerateCode(string user = "")
{
if (Verbose) Console.WriteLine("Aligning time...");
TimeAligner.AlignTime();
if (Verbose) Console.WriteLine("Opening manifest...");