Пример #1
0
        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();
        }
Пример #2
0
            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);
                }
            }
Пример #3
0
        public void AppReturnsMissingParametersReturnCodeIfMandatoryParametersAreMissing()
        {
            string[] args       = { "-l", TestConstants.EmbeddedJbossLogfile };
            var      returncode = CommandLineInterface.Main(args);

            Assert.AreEqual((int)CliReturnCodes.MissingParameters, returncode);
        }
Пример #4
0
        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);
        }
    }
Пример #6
0
        static void Main(string[] args)
        {
            CommandLineInterface CLI = new CommandLineInterface();

            CLI.Intro();
            CLI.Run();
        }
Пример #7
0
 public static CommandLineInterface getInstance()
 {
     if (instance == null)
     {
         GameObject obj = new GameObject("CommandLine");
         instance = obj.AddComponent <CommandLineInterface>();
     }
     return(instance);
 }
Пример #8
0
        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();
        }
Пример #9
0
        static void Main(string[] args)
        {
            CommandLineInterface.EnsureAdminRights();

            SetInfo(new ServiceInfo("BamHttpServer", "Bam Http Server", "Bam http application server"));

            if (!ProcessCommandLineArgs(args))
            {
                RunService <Program>();
            }
        }
Пример #10
0
        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>();
            }
        }
Пример #11
0
        static void Main(string[] args)
        {
            FileIO fileIO = new FileIO();


            VendingMachine ourVendMach = new VendingMachine(fileIO.CreateInventoryList());

            CommandLineInterface ourCLI = new CommandLineInterface(ourVendMach);

            ourCLI.Runner();
        }
Пример #12
0
            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.");
                }
            }
Пример #13
0
        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();
            }
        }
Пример #14
0
        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);
        }
Пример #15
0
        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);
        }
Пример #16
0
        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);
        }
Пример #17
0
        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();
            }
Пример #18
0
            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();
                }
            }
Пример #19
0
        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);
        }
Пример #20
0
        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);
        }
Пример #21
0
 // 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 });
     }
 }
Пример #22
0
        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);
                }
            }
        }
Пример #23
0
        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();
        }
Пример #24
0
        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);
        }
Пример #25
0
        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();
        }
Пример #27
0
        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);
        }
Пример #28
0
 public override bool Execute(CommandLineInterface cli, string arguments, out string remainder)
 {
     return(Execute(cli as Interface, arguments, out remainder));
 }
Пример #29
0
 public ParserMatcher(CommandLineInterface cli)
 {
     _CLI = cli;
 }
Пример #30
0
 private static int Main(string[] args)
 {
     return(CommandLineInterface.Main(args, TsqlStringExtractor.FromFile));
 }