示例#1
0
 public void TestParse_PassEmptyString_ReturnsError()
 {
     Assert.Throws <UnknownCommandException>(() =>
     {
         mArgsParser.Parse(string.Empty);
     });
 }
        private void _processNewCommand(string input)
        {
            var result = mArgsParser.Parse(input);

            mView.ClearInput();

            IConsoleCommand command = null;

            try
            {
                command = mCommandsTable[result.Item1];
            }
            catch (KeyNotFoundException)
            {
                mView.Log($"<color=red>Unknown command: </color> {result.Item1}");

                return;
            }

            mView.Log(input);
            mView.Log(command.Run(result.Item2));
        }
示例#3
0
        internal override async Task <int> RunAsyncOverride(string[] args, TSettings settings)
        {
            // Args are only allowed while running as a console application as they may require user input.
            if (args.Any())
            {
                return(parser.Parse(args, settings));
            }

            worker.Start();

            // Watching on a separate thread so that exceptions can be observed.
            var cancelKeyPressWatcher = new Thread(StopOnCancelKeyPress)
            {
                IsBackground = true
            };

            cancelKeyPressWatcher.Start();

            await worker.Initialization.ConfigureAwait(false);

            await worker.Completion.ConfigureAwait(false);

            return(0);
        }