2013-08-13 05:08:37 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2013-07-09 00:47:09 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Common.EnvironmentInfo
|
|
|
|
|
{
|
2013-08-13 05:08:37 +00:00
|
|
|
|
public interface IStartupArguments
|
2013-07-09 00:47:09 +00:00
|
|
|
|
{
|
2013-08-13 05:08:37 +00:00
|
|
|
|
HashSet<string> Flags { get; }
|
|
|
|
|
Dictionary<string, string> Args { get; }
|
|
|
|
|
}
|
2013-07-09 00:47:09 +00:00
|
|
|
|
|
2013-08-13 05:08:37 +00:00
|
|
|
|
public class StartupArguments : IStartupArguments
|
|
|
|
|
{
|
|
|
|
|
public const string APPDATA = "data";
|
|
|
|
|
public const string NO_BROWSER = "nobrowser";
|
2013-07-09 00:47:09 +00:00
|
|
|
|
public const string INSTALL_SERVICE = "i";
|
|
|
|
|
public const string UNINSTALL_SERVICE = "u";
|
|
|
|
|
public const string HELP = "?";
|
|
|
|
|
|
2013-08-16 02:20:54 +00:00
|
|
|
|
static StartupArguments()
|
|
|
|
|
{
|
|
|
|
|
if (RuntimeInfo.IsProduction)
|
|
|
|
|
{
|
|
|
|
|
Instance = new StartupArguments("");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-13 05:08:37 +00:00
|
|
|
|
public StartupArguments(params string[] args)
|
2013-07-09 00:47:09 +00:00
|
|
|
|
{
|
|
|
|
|
Flags = new HashSet<string>();
|
2013-08-13 05:08:37 +00:00
|
|
|
|
Args = new Dictionary<string, string>();
|
2013-07-09 00:47:09 +00:00
|
|
|
|
|
|
|
|
|
foreach (var s in args)
|
|
|
|
|
{
|
|
|
|
|
var flag = s.Trim(' ', '/', '-').ToLower();
|
2013-08-13 05:08:37 +00:00
|
|
|
|
|
|
|
|
|
var argParts = flag.Split('=');
|
|
|
|
|
|
|
|
|
|
if (argParts.Length == 2)
|
|
|
|
|
{
|
|
|
|
|
Args.Add(argParts[0].Trim(), argParts[1].Trim(' ', '"'));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Flags.Add(flag);
|
|
|
|
|
}
|
2013-07-09 00:47:09 +00:00
|
|
|
|
}
|
2013-08-13 05:08:37 +00:00
|
|
|
|
|
|
|
|
|
Instance = this;
|
2013-07-09 00:47:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public HashSet<string> Flags { get; private set; }
|
2013-08-13 05:08:37 +00:00
|
|
|
|
public Dictionary<string, string> Args { get; private set; }
|
|
|
|
|
|
|
|
|
|
public static IStartupArguments Instance { get; private set; }
|
2013-07-09 00:47:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|