Fixed args

This commit is contained in:
tidusjar 2016-04-08 14:23:26 +01:00
parent 50022cb559
commit 35310d35ed

View file

@ -50,30 +50,32 @@ namespace PlexRequests.UI
var port = -1; var port = -1;
if (args.Length > 0) if (args.Length > 0)
{ {
foreach (var a in args) for (int i = 0; i < args.Length; i++)
{ {
if (a.StartsWith("-base", StringComparison.CurrentCultureIgnoreCase)) var arg = args[i].ToLowerInvariant().Substring(1);
switch (arg)
{ {
Console.WriteLine("Settings URL Base"); case "base":
assetLocation = args[0]; i++;
} var value = args[i];
else Console.WriteLine("Settings URL Base");
{ assetLocation = value;
Log.Info("We are going to use port {0} that was passed in", a); break;
int portResult; default:
if (!int.TryParse(a, out portResult)) int portResult;
{ if (!int.TryParse(args[i], out portResult))
Console.WriteLine("Didn't pass in a valid port"); {
Console.ReadLine(); Console.WriteLine("Didn't pass in a valid port");
Environment.Exit(1); Console.ReadLine();
} Environment.Exit(1);
else }
{ else
port = portResult; {
} port = portResult;
}
break;
} }
} }
} }
Log.Trace("Getting product version"); Log.Trace("Getting product version");
WriteOutVersion(); WriteOutVersion();
@ -82,7 +84,7 @@ namespace PlexRequests.UI
var cn = s.SetupDb(assetLocation); var cn = s.SetupDb(assetLocation);
s.CacheQualityProfiles(); s.CacheQualityProfiles();
ConfigureTargets(cn); ConfigureTargets(cn);
if (port == -1) if (port == -1)
port = GetStartupPort(); port = GetStartupPort();