public static CommandLineOptions Parse(string[] args)
 {
     var options = new CommandLineOptions();
     using (var iter = args.AsEnumerable().GetEnumerator())
     {
         while (iter.MoveNext())
         {
             string arg = iter.Current;
             if (String.Equals(arg, "-LRBackendOverride", StringComparison.OrdinalIgnoreCase))
             {
                 if (!iter.MoveNext())
                     throw new CommandLineArgException("Missing value for argument " + arg);
                 options.LRBackendOverride = iter.Current;
             }
             else if (String.Equals(arg, "-LRBundledPluginsOverride", StringComparison.OrdinalIgnoreCase))
             {
                 if (!iter.MoveNext())
                     throw new CommandLineArgException("Missing value for argument " + arg);
                 options.LRBundledPluginsOverride = iter.Current;
             }
             else
             {
                 throw new CommandLineArgException("Unknown option " + arg);
             }
         }
     }
     return options;
 }
Пример #2
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            Environment.SetEnvironmentVariable("DEBUG", "*");

            // root dirs
            baseDir         = System.AppDomain.CurrentDomain.BaseDirectory;
            localAppDataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "LiveReload");
            appDataDir      = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"LiveReload\");

            // derived dirs
            resourcesDir          = Path.Combine(baseDir, @"res");
            logDir                = Path.Combine(localAppDataDir, @"Logs");
            extractedResourcesDir = Path.Combine(localAppDataDir, @"Bundled");

            Directory.CreateDirectory(appDataDir);
            Directory.CreateDirectory(logDir);

            logFile = Path.Combine(logDir, "LiveReload_" + DateTime.Now.ToString("yyyy_MM_dd_HHmmss") + ".txt");
            logWriter = TextWriter.Synchronized(new StreamWriter(logFile));
            logWriter.WriteLine("LiveReload v" + Version + " says hi.");
            logWriter.WriteLine("OS version: " + Environment.OSVersion);
            logWriter.WriteLine("Paths:");
            logWriter.WriteLine("  resourcesDir  = \"" + resourcesDir + "\"");
            logWriter.WriteLine("  appDataDir    = \"" + appDataDir + "\"");
            logWriter.WriteLine("  logDir        = \"" + logDir + "\"");
            logWriter.Flush();

            try
            {
                options = CommandLineOptions.Parse(e.Args);
            }
            catch (CommandLineArgException err)
            {
                DisplayCommandLineError(err.Message);
                Shutdown();
                return;
            }

            StartUI();
        }