public CommandLineUI(string[] args, CommandStatusWriter consoleOut) { _commandArgs = new CommandArgs(consoleOut, false); if (!_commandArgs.ParseArgs(args)) { consoleOut.WriteLine(Resources.CommandLine_Run_Exiting___); return; } Program.UnitTest = Program.FunctionalTest = true; Program.TestExceptions = new List <Exception>(); Program.NoSaveSettings = true; Program.DisableJoining = _commandArgs.ImportDisableJoining; Program.NoAllChromatogramsGraph = _commandArgs.NoAllChromatogramsGraph; Settings.Default.AutoShowAllChromatogramsGraph = !_commandArgs.HideAllChromatogramsGraph; LocalizationHelper.InitThread(); // Run test in new thread (Skyline on main thread). Program.Init(); Settings.Default.SrmSettingsList[0] = SrmSettingsList.GetDefault(); // Reset defaults with names from resources for testing different languages Settings.Default.BackgroundProteomeList[0] = BackgroundProteomeList.GetDefault(); Settings.Default.DeclusterPotentialList[0] = DeclusterPotentialList.GetDefault(); Settings.Default.RetentionTimeList[0] = RetentionTimeList.GetDefault(); Settings.Default.ShowStartupForm = false; var threadTest = new Thread(Run); LocalizationHelper.InitThread(threadTest); threadTest.Start(); Program.Main(); threadTest.Join(); }
public static void RunCommand(string[] inputArgs, CommandStatusWriter consoleOut) { using (CommandLine cmd = new CommandLine(consoleOut)) { cmd.Run(inputArgs); } }
private static void RunCommand(params string[] inputArgs) { var consoleBuffer = new StringBuilder(); var consoleOutput = new CommandStatusWriter(new StringWriter(consoleBuffer)); CommandLineRunner.RunCommand(inputArgs, consoleOutput); }
public static int RunCommand(string[] inputArgs, CommandStatusWriter consoleOut) { using (CommandLine cmd = new CommandLine(consoleOut)) { return(cmd.Run(inputArgs)); } }
protected static string RunCommand(params string[] inputArgs) { var consoleBuffer = new StringBuilder(); var consoleOutput = new CommandStatusWriter(new StringWriter(consoleBuffer)); CommandLineRunner.RunCommand(inputArgs, consoleOutput); return(consoleBuffer.ToString()); }
private static SrmDocument InitWatersImsMseDocument(TestFilesDir testFilesDir, string skyFile, RefinementSettings.ConvertToSmallMoleculesMode asSmallMolecules, out string docPath) { docPath = testFilesDir.GetTestPath(skyFile); var consoleBuffer = new StringBuilder(); var consoleOutput = new CommandStatusWriter(new StringWriter(consoleBuffer)); var cmdline = new CommandLine(consoleOutput); Assert.IsTrue(cmdline.OpenSkyFile(docPath)); // Handles any path shifts in database files, like our .imdb file SrmDocument doc = cmdline.Document; var refine = new RefinementSettings(); doc = refine.ConvertToSmallMolecules(doc, asSmallMolecules); return(doc); }
/// <summary> /// This function will try for 5 seconds to open a named pipe ("SkylineInputPipe"). /// If this operation is not successful, the function will exit. Otherwise, /// the function will print each line received from the pipe /// out to the console and then wait for a newline from the user. /// </summary> public void Start(string arg0) { string guidSuffix = RemoveCommandPrefix(arg0); List <string> args = new List <string>(); using (NamedPipeClientStream pipeStream = new NamedPipeClientStream("SkylineInputPipe" + guidSuffix)) // Not L10N { // The connect function will wait 5s for the pipe to become available try { pipeStream.Connect(5 * 1000); } catch (Exception) { // Nothing to output, because no connection to command-line process. return; } using (StreamReader sr = new StreamReader(pipeStream)) { string line; //While (!done reading) while ((line = sr.ReadLine()) != null) { args.Add(line); } } } string outPipeName = "SkylineOutputPipe" + guidSuffix; // Not L10N using (var serverStream = new NamedPipeServerStream(outPipeName)) // Not L10N { var namedPipeServerConnector = new NamedPipeServerConnector(); if (!namedPipeServerConnector.WaitForConnection(serverStream, outPipeName)) { return; } using (var sw = new CommandStatusWriter(new StreamWriter(serverStream))) { RunCommand(args.ToArray(), sw); } } }
public static void Main(string[] args = null) { if (String.IsNullOrEmpty(Settings.Default.InstallationId)) // Each instance to have GUID { Settings.Default.InstallationId = Guid.NewGuid().ToString(); } // don't allow 64-bit Skyline to run in a 32-bit process if (Install.Is64Bit && !Environment.Is64BitProcess) { string installUrl = Install.Url; string installLabel = (installUrl == string.Empty) ? string.Empty : string.Format(Resources.Program_Main_Install_32_bit__0__, Name); AlertLinkDlg.Show(null, string.Format(Resources.Program_Main_You_are_attempting_to_run_a_64_bit_version_of__0__on_a_32_bit_OS_Please_install_the_32_bit_version, Name), installLabel, installUrl); return; } CommonFormEx.TestMode = FunctionalTest; CommonFormEx.Offscreen = SkylineOffscreen; CommonFormEx.ShowFormNames = FormEx.ShowFormNames = ShowFormNames; // For testing and debugging Skyline command-line interface if (args != null && args.Length > 0) { if (!CommandLineRunner.HasCommandPrefix(args[0])) { TextWriter textWriter; if (Debugger.IsAttached) { textWriter = new DebugWriter(); } else { AttachConsole(-1); textWriter = Console.Out; Console.WriteLine(); Console.WriteLine(); } var writer = new CommandStatusWriter(textWriter); if (args[0].Equals("--ui", StringComparison.InvariantCultureIgnoreCase)) // Not L10N { // ReSharper disable once ObjectCreationAsStatement new CommandLineUI(args, writer); } else { CommandLineRunner.RunCommand(args, writer); } } else { // For testing SkylineRunner without installation CommandLineRunner clr = new CommandLineRunner(); clr.Start(args[0]); } return; } // The way Skyline command-line interface is run for an installation else if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null && AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData != null && AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData.Length > 0 && CommandLineRunner.HasCommandPrefix(AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0])) // Not L10N { CommandLineRunner clr = new CommandLineRunner(); clr.Start(AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0]); // HACK: until the "invalid string binding" error is resolved, this will prevent an error dialog at exit Process.GetCurrentProcess().Kill(); return; } try { Init(); if (!string.IsNullOrEmpty(Settings.Default.DisplayLanguage)) { try { LocalizationHelper.CurrentUICulture = CultureInfo.GetCultureInfo(Settings.Default.DisplayLanguage); } catch (CultureNotFoundException) { } } LocalizationHelper.InitThread(Thread.CurrentThread); // Make sure the user has agreed to the current license version // or one more recent. int licenseVersion = Settings.Default.LicenseVersionAccepted; if (licenseVersion < LICENSE_VERSION_CURRENT && !NoSaveSettings) { // If the user has never used the application before, then // they must have agreed to the current license agreement during // installation. Otherwise, make sure they agree to the new // license agreement. if (Install.Type == Install.InstallType.release && (licenseVersion != 0 || !Settings.Default.MainWindowSize.IsEmpty)) { using (var dlg = new UpgradeDlg(licenseVersion)) { if (dlg.ShowDialog() == DialogResult.Cancel) { return; } } } try { // Make sure the user never sees this again for this license version Settings.Default.LicenseVersionAccepted = LICENSE_VERSION_CURRENT; Settings.Default.Save(); } // ReSharper disable EmptyGeneralCatchClause catch (Exception) // ReSharper restore EmptyGeneralCatchClause { // Just try to update the license version next time. } } try { // If this is a new installation copy over installed external tools from previous installation location. var toolsDirectory = ToolDescriptionHelpers.GetToolsDirectory(); if (!Directory.Exists(toolsDirectory)) { using (var longWaitDlg = new LongWaitDlg { Text = Name, Message = Resources.Program_Main_Copying_external_tools_from_a_previous_installation, ProgressValue = 0 }) { longWaitDlg.PerformWork(null, 1000 * 3, broker => CopyOldTools(toolsDirectory, broker)); } } } // ReSharper disable once EmptyGeneralCatchClause catch { } // Force live reports (though tests may reset this) //Settings.Default.EnableLiveReports = true; if (ReportShutdownDlg.HadUnexpectedShutdown()) { using (var reportShutdownDlg = new ReportShutdownDlg()) { reportShutdownDlg.ShowDialog(); } } SystemEvents.DisplaySettingsChanged += SystemEventsOnDisplaySettingsChanged; // Careful, a throw out of the SkylineWindow constructor without this // catch causes Skyline just to appear to silently never start. Makes for // some difficult debugging. try { var activationArgs = AppDomain.CurrentDomain.SetupInformation.ActivationArguments; if ((activationArgs != null && activationArgs.ActivationData != null && activationArgs.ActivationData.Length != 0) || !Settings.Default.ShowStartupForm) { MainWindow = new SkylineWindow(args); } else { StartWindow = new StartPage(); try { if (StartWindow.ShowDialog() != DialogResult.OK) { Application.Exit(); return; } MainWindow = StartWindow.MainWindow; } finally { StartWindow.Dispose(); StartWindow = null; } } } catch (Exception x) { ReportExceptionUI(x, new StackTrace(1, true)); } ConcurrencyVisualizer.StartEvents(MainWindow); // Position window offscreen for stress testing. if (SkylineOffscreen) { FormEx.SetOffscreen(MainWindow); } ActionUtil.RunAsync(() => { try { SendAnalyticsHit(); } catch (Exception ex) { Trace.TraceWarning("Exception sending analytics hit {0}", ex); // Not L10N } }); MainToolServiceName = Guid.NewGuid().ToString(); Application.Run(MainWindow); StopToolService(); } catch (Exception x) { // Send unhandled exceptions to the console. Console.WriteLine(x.Message); Console.Write(x.StackTrace); } MainWindow = null; }