public void With_AllParsedOptions() { // Arrange const bool isCountAllVisitsNeeded = true; const bool isPlayMode = true; const bool isVerboseMode = true; const bool isKeepRunningAfterStoryFinishedNeeded = true; var pluginNames = new List <string>(); var parsedOptions = new ParsedCommandLineOptions() { IsCountAllVisitsNeeded = isCountAllVisitsNeeded, IsPlayMode = isPlayMode, IsVerboseMode = isVerboseMode, IsKeepOpenAfterStoryFinishNeeded = isKeepRunningAfterStoryFinishedNeeded, PluginNames = pluginNames, }; var processedOptions = new CommandLineToolOptions(); var tool = new CommandLineTool(); // Act tool.ProcesFlags(parsedOptions, processedOptions); // Assert parsedOptions.Should().NotBeNull("because the parsed options object was given"); processedOptions.Should().NotBeNull("because the processed options object was given"); processedOptions.IsCountAllVisitsNeeded.Should().Be(isCountAllVisitsNeeded, "because it was given"); processedOptions.IsPlayMode.Should().Be(isPlayMode, "because it was given"); processedOptions.IsVerboseMode.Should().Be(isVerboseMode, "because it was given"); processedOptions.IsKeepRunningAfterStoryFinishedNeeded.Should().Be(isKeepRunningAfterStoryFinishedNeeded, "because it was given"); processedOptions.PluginNames.Should().BeEquivalentTo(pluginNames, "because it was given"); }
public static void ExecuteCommand_Throws(string command, string args, string workingDirectory, int waitMilliseconds) { var commandLineTool = new CommandLineTool(); Assert.That( () => commandLineTool.ExecuteCommand(command, args, workingDirectory, waitMilliseconds), Throws.TypeOf <ArgumentException>() .With.Message.Contains(" must ")); }
public void With_NullArguments() { // Arrange var tool = new CommandLineTool(); // Act tool.ProcesInputFilePath(null, null, null); // Assert // Without arguments the function should process nothing. }
public void WithoutArguments() { // Arrange var tool = new CommandLineTool(); // Act tool.ReadFileText(null, null); // Assert // Without arguments the function should process nothing. }
private static void Main(string[] args) { Console.Title = "BriefingRoom output console"; DebugLog.Instance.CreateLogFileWriter(); using (INIFile ini = new INIFile($"{BRPaths.DATABASE}Common.ini")) TARGETED_DCS_WORLD_VERSION = ini.GetValue("Versions", "DCSVersion", "2.5"); if (args.Length > 0) // Command-line arguments are present, use the command-line tool { Database.Instance.Initialize(); // Called here in command-line mode, when in GUI mode function is called by the SplashScreen if (DebugLog.Instance.ErrorCount > 0) { return; // Errors found, abort! abort! } try { using (CommandLineTool clt = new CommandLineTool()) clt.DoCommandLine(args); } catch (Exception ex) { Console.WriteLine($"ERROR: {ex.Message}"); } #if DEBUG Console.WriteLine(); Console.WriteLine("Press any key to close this window"); Console.ReadKey(); #endif } else // No command-line, use the GUI tool { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Display the splash screen while the database is being loaded using (SplashScreenForm splashScreen = new SplashScreenForm()) { splashScreen.ShowDialog(); if (splashScreen.AbortStartup) { return; } } Application.Run(new MainForm()); } DebugLog.Instance.CloseLogFileWriter(); }
public Startup(IConfiguration configuration, IHostEnvironment env) { Configuration = configuration; #if DEBUG var root = env.ContentRootPath; ContentRootPath = Path.Combine(root, "ClientApp"); if (Directory.Exists(ContentRootPath)) { CommandLineTool.Run("npm run dev", ContentRootPath); } #endif }
public Startup(IConfiguration configuration, IHostEnvironment env) { Configuration = configuration; var root = env.ContentRootPath; ContentRootPath = Path.Combine(root, "ClientApp"); CommandLineTool.Run("set BROWSER=none&&npm start", ContentRootPath, output => { if (output.Contains("localhost:3000")) { CommandLineTool.Run("electron .", ContentRootPath); } }); }
public void With_MockedFileSystemInteraction() { // Arrange string inputFileDirectory = @"c:\Test"; string inputFileName = "test.ink"; var tool = new CommandLineTool(); tool.FileSystemInteractor = Substitute.For <IFileSystemInteractable>(); // Act string fileContents = tool.ReadFileText(inputFileDirectory, inputFileName); // Assert fileContents.Should().BeNullOrEmpty("because the file system interactor was substituted"); }
static void ReadLine() { var a = In.ReadLine(); var packs = CommandLineTool.Analyze(a); foreach (var item in packs.RealParameter) { //Console.WriteLine("Enq:"+item.EntireArgument); Input.Enqueue(item.EntireArgument); } if (Input.Count == 0) { ReadLine(); } }
public override void Process(PublishContext context) { foreach (string name in context.PublishOptions.PublishingTargets) { string path = "/sitecore/system/publishing targets/" + name; Sitecore.Data.Items.Item target = context.PublishOptions.SourceDatabase.GetItem(path); Sitecore.Diagnostics.Assert.IsNotNull(target, path); string command = target["CommandLine"]; if (String.IsNullOrEmpty(command)) { return; } CommandLineTool clt = new CommandLineTool(command); clt.Execute(true); } }
public static void ExecuteCommand_ReturnsExpectedResult_WhenCommandSucceeds() { var commandLineTool = new CommandLineTool(); var result = commandLineTool.ExecuteCommand("cmd", "/c echo Hi", ".", 1000); Assert.That(result, Is.Not.Null); Assert.That(result.HasExited, Is.True); Assert.That(result.ExitCode, Is.EqualTo(0)); Assert.That(result.StandardOutput.BaseStream.CanRead, Is.True); Assert.That(result.StandardError.BaseStream.CanRead, Is.True); var errorOutput = result.StandardError.ReadToEnd(); var standardOutput = result.StandardOutput.ReadToEnd(); Assert.That(errorOutput.Length, Is.EqualTo(0)); Assert.That(standardOutput.Length, Is.GreaterThan(0)); StringAssert.Contains("Hi", standardOutput); }
public void With_ExceptionThrowingReadFile() { // Arrange string inputFileDirectory = @"c:\Test"; string inputFileName = "test.ink"; var fileSystemInteractorMock = Substitute.For <IFileSystemInteractable>(); fileSystemInteractorMock.When(x => x.ReadAllTextFromFile(Arg.Any <string>())) .Do(x => throw new System.IO.DirectoryNotFoundException()); var tool = new CommandLineTool(); tool.FileSystemInteractor = fileSystemInteractorMock; // Act string fileContents = tool.ReadFileText(inputFileDirectory, inputFileName); // Assert fileContents.Should().BeNullOrEmpty("because the file system interactor was substituted"); }
public void With_InputFountainFile() { // Arrange const string inputFilePath = @"generating_testfile.ink"; const string startingDirectory = @"C:\Test"; var parsedOptions = new ParsedCommandLineOptions() { InputFilePath = inputFilePath }; var processedOptions = new CommandLineToolOptions(); var tool = new CommandLineTool(); // Act tool.ProcesOutputFountainFilePath(parsedOptions, processedOptions, startingDirectory); // Assert parsedOptions.Should().NotBeNull("because the parsed options object was given"); processedOptions.Should().NotBeNull("because the processed options object was given"); processedOptions.RootedOutputFountainFilePath.Should().Be(@"C:\Test\generating_testfile.ink.fountain", "because it was given"); }
public void With_RootedOutputFilePath() { // Arrange const string outputFilePath = @"C:\Test\testfile.ink.json"; const string startingDirectory = @"C:\Test"; var parsedOptions = new ParsedCommandLineOptions() { OutputFilePath = outputFilePath }; var processedOptions = new CommandLineToolOptions(); var tool = new CommandLineTool(); // Act tool.ProcesOutputFilePath(parsedOptions, processedOptions, startingDirectory); // Assert parsedOptions.Should().NotBeNull("because the parsed options object was given"); processedOptions.Should().NotBeNull("because the processed options object was given"); processedOptions.RootedOutputFilePath.Should().Be(outputFilePath, "because it was given"); }
public Startup(IConfiguration configuration, IHostEnvironment env) { Configuration = configuration; #if DEBUG var root = env.ContentRootPath; ContentRootPath = Path.Combine(root, "ClientApp"); if (Directory.Exists(ContentRootPath)) { CommandLineTool.Run("npm start", ContentRootPath, output => { if (output.Contains("development server")) { CommandLineTool.Run("npm run start-electron", ContentRootPath); } }); } #endif }
public static void ExecuteCommand__ReturnsExpectedResult_WhenCommandFails() { var commandLineTool = new CommandLineTool(); var result = commandLineTool.ExecuteCommand("cmd", "/c dir ThisIsAJunkFileNameAndShouldNotExist", ".", 1000); Assert.That(result, Is.Not.Null); Assert.That(result.HasExited, Is.True); Assert.That(result.ExitCode, Is.EqualTo(1)); Assert.That(result.StandardOutput.BaseStream.CanRead, Is.True); Assert.That(result.StandardError.BaseStream.CanRead, Is.True); var errorOutput = result.StandardError.ReadToEnd(); var standardOutput = result.StandardOutput.ReadToEnd(); Assert.That(errorOutput.Length, Is.GreaterThan(0)); StringAssert.Contains("File Not Found", errorOutput); Assert.That(standardOutput.Length, Is.GreaterThan(0)); StringAssert.Contains("Directory of", standardOutput); }
public void With_CountAllVisitsAndOutputFile() { // Arrange var options = new ParsedCommandLineOptions(); const string ArgumentString = "-c test.ink"; string[] args = ArgumentString.Split(" "); var tool = new CommandLineTool(); // Act tool.ParseArguments(args, options); // Assert options.Should().NotBeNull("because the parsing should succeed"); options.InputFilePath.Should().BeEquivalentTo("test.ink"); options.OutputFilePath.Should().BeNull("because none was given"); options.IsCountAllVisitsNeeded.Should().BeTrue("because the count all visits flag was set"); options.IsPlayMode.Should().BeFalse("because the playmode flag was not set"); options.IsVerboseMode.Should().BeFalse("because the verbose flag was not set"); options.IsKeepOpenAfterStoryFinishNeeded.Should().BeFalse("because the keep running after finished flag was not set"); }
public static void Build() { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, BuildTarget.Android); List <string> sceneList = new List <string>(); EditorBuildSettingsScene[] temp = EditorBuildSettings.scenes; for (int i = 0, iMax = temp.Length; i < iMax; ++i) { sceneList.Add(temp[i].path); } string path = GetBuildPathAndroid(); Debug.Log("StartBuild!"); Debug.Log("JenkinsParams: " + GetJenkinsParameter()); if (CommandLineTool.HasCommandArgs(CommandArgsName.Channel)) { Debug.Log("JenkinsCommandParams: " + CommandLineTool.GetEnvironmentVariable(CommandArgsName.Channel)); } BuildPipeline.BuildPlayer(sceneList.ToArray(), path, BuildTarget.Android, BuildOptions.None); }
public void With_InputFile() { // Arrange const string inputFilePath = @"testfile.ink"; const string startingDirectory = @"C:\SomeFolder"; var parsedOptions = new ParsedCommandLineOptions() { InputFilePath = inputFilePath }; var processedOptions = new CommandLineToolOptions(); var tool = new CommandLineTool(); // Act tool.ProcesInputFilePath(parsedOptions, processedOptions, startingDirectory); // Assert parsedOptions.Should().NotBeNull("because the parsed options object was given"); processedOptions.Should().NotBeNull("because the processed options object was given"); processedOptions.InputFilePath.Should().Be(inputFilePath, "because it was given"); processedOptions.InputFileName.Should().Be(@"testfile.ink", "because that is the filename part of the path"); processedOptions.RootedInputFilePath.Should().Be(@"C:\SomeFolder\testfile.ink", "because combines the starting directory with the filename"); processedOptions.InputFileDirectory.Should().Be(startingDirectory, "because the starting directory should be the default"); }
public static void CurrentDomain_ProcessExit(object sender, EventArgs e) { CommandLineTool.Close(); }
public static void Constructor_Succeeds() { var result = new CommandLineTool(); Assert.That(result, Is.Not.Null); }
internal string RealProcess(string[] lines, bool isMainFile) { StringBuilder stringBuilder = new StringBuilder(); bool isIgnore = false; JSInfo info; if (isMainFile) { info = this.info; } else { info = new JSInfo(); } for (int i = 0; i < lines.Length; i++) { var item = lines[i]; if (item.Trim().StartsWith("///") || item.Trim().StartsWith("#")) { //Macro var macro = item.Trim(); if (item.Trim().StartsWith("///")) { macro = macro.Substring(3).Trim(); } else { macro = macro.Substring(1).Trim(); } if (macro == "") { continue; } var m0 = CommandLineTool.Analyze(macro); bool willDisposeLine = false; switch (m0.RealParameter[0].EntireArgument.ToUpper()) { case "DEFINE": { if (isIgnore is not true) { if (settings.RemoveDefineMacro) { willDisposeLine = true; } var Key = m0.RealParameter[1].EntireArgument; switch (Key.ToUpper()) { case "NAME": { if (settings.PreserveModuleInfoMacro && isMainFile) { willDisposeLine = false; } info.Name = m0.RealParameter[2].EntireArgument; } break; case "AUTHOR": { if (settings.PreserveModuleInfoMacro && isMainFile) { willDisposeLine = false; } info.Author = m0.RealParameter[2].EntireArgument; } break; case "VERSION": { if (settings.PreserveModuleInfoMacro && isMainFile) { willDisposeLine = false; } info.Version = new Version(m0.RealParameter[2].EntireArgument); } break; default: { this.info.Flags.Add(Key); } break; } } } break; case "USING": { if (isIgnore is not true) { if (m0.RealParameter[1].EntireArgument.ToUpper() == "JS") { if (settings.RemoveUsingJSMacro) { willDisposeLine = true; } var f = FindJS(m0.RealParameter[2].EntireArgument); if (f is not null) { item = Process(f, false); stringBuilder.Append(item); continue; // Force skip this to avoid duplicate code. } else { throw new Exception("Target JS file not found:" + m0.RealParameter[2].EntireArgument); } //Pre-Combine JavaScript Codes. } else if (m0.RealParameter[1].EntireArgument.ToUpper() == "DLL") { info.UsingDLLs.Add(m0.RealParameter[2]); } } } break; case "INCLUDE": { if (isIgnore is not true) { var f = FindJS(m0.RealParameter[1].EntireArgument); if (f is not null) { item = Process(f, false); stringBuilder.Append(item); continue; // Force skip this to avoid duplicate code. } else { throw new Exception("Target JS file not found:" + m0.RealParameter[2].EntireArgument); } } } break; case "IFDEF": { isIgnore = true; foreach (var flag in this.info.Flags) { if (m0.RealParameter[1].EntireArgument == flag) { isIgnore = false; break; } } } break; case "ENDIF": { isIgnore = false; } break; case "IFNDEF": { isIgnore = false; foreach (var flag in this.info.Flags) { if (m0.RealParameter[1].EntireArgument == flag) { isIgnore = true; break; } } } break; case "EXPOSETYPE": { if (isIgnore is not true) { var Name = m0.RealParameter[1].EntireArgument; var Path = m0.RealParameter[2].EntireArgument; if (settings.PreserveExposeTypeMacro == true) { willDisposeLine = false; } if (!info.ExposedTypes.ContainsKey(Name)) { info.ExposedTypes.Add(Name, Path); } else { info.ExposedTypes[Name] = Path; } } } break; default: break; } if (settings.RemoveAllMacros is true) { willDisposeLine = true; } if (willDisposeLine) { continue; } } else if (item.Trim().StartsWith("//")) { //isIgnore = settings.DisposeSingleLineComment && (!settings.PreserveSingleLineCommentInMainFile || isMainFile ==false); continue; } if (isIgnore is not true) { if (item.Trim().StartsWith("#")) { stringBuilder.Append("///"); stringBuilder.Append(item.Trim().Substring(1)); } else { stringBuilder.Append(item); } stringBuilder.Append(Environment.NewLine); } } if (!isMainFile) { this.info.SubModules.Add(info); } return(stringBuilder.ToString()); }