public void Process() { CommandLineInterface.Write(CLIMessages.WELLCOME_TO_DRAWING_PROGRAM); UserCommand userCommand = null; Canvas canvas = null; do { try { CommandLineInterface.Write(CLIMessages.STANDARD_SEPARATOR); userCommand = CommandLineInterface.WaitForUserCommand("Type your command: "); CommandLineInterface.Write(this.GetDrawingProgramAnswerForUserCommand(userCommand, ref canvas)); } catch (DrawingException ex) { CommandLineInterface.Write($"Drawing exception: {ex.Message}"); } catch (ShapeException ex) { CommandLineInterface.Write($"Shape exception: {ex.Message}"); } catch (ArgumentException ex) { CommandLineInterface.Write($"Argument exception: {ex.Message}"); } catch (Exception ex) { CommandLineInterface.Write($"Exception: {ex.Message}"); } } while (userCommand != null && userCommand.Command != EnumCommand.Q); Console.ReadKey(); }
public static void ProcessWhat(string line) { if (CommandLineInterface.AwaitConfirmationKeyPress("Is there a problem? Don't say yes. (Y/N) ")) { Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("\n\nThis is unacceptible."); Console.ResetColor(); System.Threading.Thread.Sleep(5000); } else { Console.WriteLine(); for (int i = 1; i <= 3; ++i) { System.Threading.Thread.Sleep(1000); Console.Write(". "); } System.Threading.Thread.Sleep(1000); Console.WriteLine("Good."); System.Threading.Thread.Sleep(2000); } }
public void AppReturnsMissingParametersReturnCodeIfMandatoryParametersAreMissing() { string[] args = { "-l", TestConstants.EmbeddedJbossLogfile }; var returncode = CommandLineInterface.Main(args); Assert.AreEqual((int)CliReturnCodes.MissingParameters, returncode); }
public void AppReturnsFileNotFoundReturnCodeIfFileIsMissing() { string[] args = { "-l", "not/existing/log.file", "-d", "not/existing/definitions.file" }; var returncode = CommandLineInterface.Main(args); Assert.AreEqual((int)CliReturnCodes.FileNotFound, returncode); }
// Update is called once per frame void Update() { getInput(); if (!isCliActivated && backtickInput) { isCliActivated = true; if (timeStopsWhenCLIActivated == true) // since this option is checked, set time to stop { Command command = new Command("time.stop"); gameInterpreter.enqueueCommand(command); } CommandLineInterface cli = CommandLineInterface.getInstance(); cli.OpenCommandLine(); // now turn off all controls for player movement controller PlayerMovementController playerMovementController; } else if (isCliActivated && backtickInput) { isCliActivated = false; CommandLineInterface cli = CommandLineInterface.getInstance(); cli.CloseCommandLine(); // resume game time Command command = new Command("time.resume"); gameInterpreter.enqueueCommand(command); } }
static void Main(string[] args) { CommandLineInterface CLI = new CommandLineInterface(); CLI.Intro(); CLI.Run(); }
public static CommandLineInterface getInstance() { if (instance == null) { GameObject obj = new GameObject("CommandLine"); instance = obj.AddComponent <CommandLineInterface>(); } return(instance); }
async static void Run() { var userManager = new UserManager(); var taskManager = new TaskManager(userManager); var eventHub = EventHub.GetInstance(); var controller = new MainController(taskManager, userManager, eventHub); var ui = new CommandLineInterface(controller, eventHub); ui.Run(); }
static void Main(string[] args) { CommandLineInterface.EnsureAdminRights(); SetInfo(new ServiceInfo("BamHttpServer", "Bam Http Server", "Bam http application server")); if (!ProcessCommandLineArgs(args)) { RunService <Program>(); } }
static void Main(string[] args) { CommandLineInterface.EnsureAdminRights(); SetInfo(new ServiceInfo("BamFileChunker", "Bam File Chunker", "Bam File Chunker: chunks files and serves chunks")); if (!ProcessCommandLineArgs(args)) { RunService <Chunker>(); } }
static void Main(string[] args) { FileIO fileIO = new FileIO(); VendingMachine ourVendMach = new VendingMachine(fileIO.CreateInventoryList()); CommandLineInterface ourCLI = new CommandLineInterface(ourVendMach); ourCLI.Runner(); }
public static void LoadTranscript(string line) { bool loadedFile; string command = null, complement = null; SplitImperative(line, ref command, ref complement); try { switch (command) { case "dir": { SplitImperative(complement, ref command, ref complement); loadedFile = command.Equals(Operators.Verbs.Commands.current) ? LoadFromDirectoryToTranscript(Preferences.default_directory) : LoadFromDirectoryToTranscript(complement.Trim()); break; } case "file": loadedFile = LoadFileIntoTranscript(complement.Trim()); break; case "files": loadedFile = LoadFilesIntoTranscript(complement); break; default: { loadedFile = String.IsNullOrWhiteSpace(complement) ? LoadFromDirectoryToTranscript(Preferences.default_directory) : LoadFilesIntoTranscript(complement); break; } } } catch (Exception e) { CommandLineInterface.ShowError(Preferences.FIRST_INDENTATION + "Error : " + e.Message); loadedFile = false; } if (!loadedFile) { Console.WriteLine("\nNone of the pages specified were loaded successfully."); } }
static void Main(string[] args) { var cli = new CommandLineInterface(); cli.Execute(args); if (System.Diagnostics.Debugger.IsAttached) { Console.WriteLine("Press a key to exit..."); Console.ReadKey(); } }
public static void Main(string[] args) { var logger = new ConsoleLogger(); var cli = new CommandLineInterface( logger: logger, printGenerators: new List <IPrintGeneratorManager> { new PrintGeneratorManager <SingleMaterialFFFPrintGenerator, SingleMaterialFFFSettings>( new GenericRepRapSettings(), "fff", "Basic FFF prints", logger) }); cli.Execute(args); }
public static void Main(string[] args) { var rootCommand = new RootCommand("voicekit"); var recognitionCommand = CommandLineInterface.CreateRecognitionCommand(); var streamingRecognitionCommand = CommandLineInterface.CreateStreamingRecognitionCommand(); var streamingSynthesisCommand = CommandLineInterface.CreateStreamingSynthesisCommand(); rootCommand.AddCommand(recognitionCommand); rootCommand.AddCommand(streamingRecognitionCommand); rootCommand.AddCommand(streamingSynthesisCommand); rootCommand.Invoke(args); }
private static async Task Main(string[] args) { var helloWorldCommand = new DelegateCommand( "hello-world", "Output \"Hello World !\"", async c => { Console.WriteLine("Hello World !"); return(0); }); var app = new CommandLineInterface("sample-cli", "Sample CLI", helloWorldCommand); await app.RunAsync(args); }
public override bool Execute(CommandLineInterface cli, string arguments, out string remainder) { var commands = cli.Commands; foreach (var command in commands) { Console.ForegroundColor = ConsoleColor.Cyan; Console.Write($" {command.name}"); Console.ForegroundColor = ConsoleColor.DarkGray; Console.Write($"{(command.command.HelpfulArguments == string.Empty ? string.Empty : $" {command.command.HelpfulArguments}")}"); Console.Write(" => "); Console.ForegroundColor = ConsoleColor.White; Console.Write(command.command.HelpMessage); Console.WriteLine(); }
public static void ClearTranscript(string line) { if ( GetVerb(line).Equals(Operators.Verbs.Commands.force) || CommandLineInterface.AwaitConfirmationKeyPress ( "This will erase all definitions currently loaded in the transcript.\nContinue? (Y/N) " ) ) { Definition.Clear(); Transcript.Clear(); } }
public override bool Execute(CommandLineInterface cli, string arguments, out string remainder) { if (cli.currentRawFile == null) { cli.Warn("No iwd file was loaded! Nothing was unloaded."); } cli.currentRawFile?.Dispose(); cli.currentRawFile = null; cli.Log($"Unloaded iwd file {cli.currentRawFilePath}"); cli.currentRawFilePath = null; remainder = arguments; return(true); }
public override bool Execute(CommandLineInterface cli, string arguments, out string remainder) { if (cli.currentRawFile == null) { cli.Warn("No iwd file was loaded! Nothing to commit."); remainder = string.Empty; return(false); } else { cli.currentRawFile.Dispose(); cli.currentRawFile = ZipFile.Open(cli.currentRawFilePath, ZipArchiveMode.Update); cli.Log($"Committed all changes to iwd file {cli.currentRawFilePath}"); } remainder = arguments; return(true); }
// Use this for initialization void Start() { if (instance != null && instance != this) { Destroy(this); } else { instance = this; gameObject.SetActive(false); // this object starts out disabled gameInterpreter = GameInterpreter.getInstance(); commandLineText = GetComponentInChildren <Text>(); // get the text object to hold the text commandLineText.text = cliPromptText; // set the text to start with the prompt text scrollbar = GetComponentInChildren <ScrollRect>(); canvas = GetComponentInParent <Canvas>(); commandHistory = ""; // set history empty string terminationCharacterStr = new string(new char[] { terminationCharacter }); } }
protected internal static void InvokeTest(ConsoleMethod consoleMethod, Func <MethodInfo, object[]> parameterProvider, bool isolateMethodCalls = true) { object[] parameters = parameterProvider(consoleMethod.Method); MethodInfo invokeTarget = typeof(ConsoleMethod).GetMethod("Invoke"); if (consoleMethod.Method.IsStatic) { if (isolateMethodCalls) { CommandLineInterface.InvokeInSeparateAppDomain(invokeTarget, consoleMethod); } else { CommandLineInterface.InvokeInCurrentAppDomain(invokeTarget, consoleMethod); } } else { string typeName = consoleMethod.Method.DeclaringType.Name; ConstructorInfo ctor = consoleMethod.Method.DeclaringType.GetConstructor(Type.EmptyTypes); if (ctor == null) { ExceptionHelper.ThrowInvalidOperation("The declaring type {0} of method {1} does not have a parameterless constructor, test cannot be run.", typeName, consoleMethod.Method.Name); } object instance = ctor.Invoke(null); Expect.IsNotNull(instance, string.Format("Unable to instantiate declaring type {0} of method {1}", typeName, consoleMethod.Method.Name)); consoleMethod.Provider = instance; if (isolateMethodCalls) { CommandLineInterface.InvokeInSeparateAppDomain(invokeTarget, consoleMethod); } else { CommandLineInterface.InvokeInCurrentAppDomain(invokeTarget, consoleMethod); } } }
static void Main(string[] args) { PyroProxy proxy; if (args.Length > 0) { proxy = StartClient(args[0]); } else { proxy = StartClient("PYRO:exec@localhost:7543"); } Console.WriteLine("**********************************************"); Console.WriteLine("*** Welcome to Events Agenda Application ***"); Console.WriteLine("**********************************************"); CommandLineInterface cli = new CommandLineInterface(proxy); cli.HandleCliStart(); proxy.close(); }
public override bool Execute(CommandLineInterface cli, string arguments, out string remainder) { string rawFilePath = CommandLineInterface.GetFirstString(arguments, out remainder); if (rawFilePath.Length == 0) { cli.Err("Please specify a path to load."); return(false); } try { cli.currentRawFile = ZipFile.Open(rawFilePath, ZipArchiveMode.Update); cli.currentRawFilePath = rawFilePath; cli.Log($"Successfully opened {rawFilePath} for import/export operations"); } catch (System.IO.IOException e) { cli.Err(e.ToString()); return(false); } return(true); }
public override bool Execute(CommandLineInterface cli, string arguments, out string remainder) { if (arguments.Length == 0) { cli.Log($"We are currently in {Directory.GetCurrentDirectory()}"); remainder = arguments; } else { var newPath = CommandLineInterface.GetFirstString(arguments, out remainder); try { Directory.SetCurrentDirectory(newPath); cli.Log($"We are now in {Directory.GetCurrentDirectory()}"); } catch (System.IO.DirectoryNotFoundException) { cli.Err($"The directory or a part of the directory {newPath} could not be found."); return(false); } } return(true); }
static void Main(string[] args) { var commandLineInterface = new CommandLineInterface(); commandLineInterface.RequestPathParamatersFromUser(); }
public override bool Execute(CommandLineInterface cli, string arguments, out string remainder) { string weaponPath = CommandLineInterface.GetFirstString(arguments, out remainder); if (weaponPath.Length == 0) { cli.Err("Please specify a path to the weapon file to import"); return(false); } string writePath = CommandLineInterface.GetFirstString(remainder, out remainder); if (writePath.Length == 0) { cli.Err("Please specify an output path to write the file either inside the iwd file or on disk"); return(false); } Model.Weapon weapon; if (!File.Exists(weaponPath)) { cli.Err($"Could not find the file {weaponPath}"); return(false); } string allText = File.ReadAllText(weaponPath); switch (System.IO.Path.GetExtension(weaponPath).ToUpper()) { case ".XML": weapon = Model.Weapon.FromXML(allText); break; case ".JSON": weapon = Model.Weapon.FromJSON(allText); break; default: cli.Err($"Unknown format {System.IO.Path.GetExtension(weaponPath)}, will not read it."); return(false); } var finalPath = writePath; var contents = weapon.SerializeToIW(); if (cli.currentRawFile == null) { File.WriteAllText(finalPath, contents); cli.Log($"Successfully wrote output file to {finalPath}."); } else { cli.currentRawFile.GetEntry(writePath).Delete(); var entry = cli.currentRawFile.CreateEntry(writePath); using (var stream = entry.Open()) { using (StreamWriter writer = new StreamWriter(stream)) { writer.Write(contents); cli.Log($"Successfully wrote output file to {cli.currentRawFilePath}. Don't forget to COMMIT to validate the changes."); } } } return(true); }
public override bool Execute(CommandLineInterface cli, string arguments, out string remainder) { return(Execute(cli as Interface, arguments, out remainder)); }
public ParserMatcher(CommandLineInterface cli) { _CLI = cli; }
private static int Main(string[] args) { return(CommandLineInterface.Main(args, TsqlStringExtractor.FromFile)); }