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