Ejemplo n.º 1
0
 public abstract bool IsRunnable(Options args);
Ejemplo n.º 2
0
        private void ProgramMain(string[] args)
        {
            if (args.Length < 1)
            {
                IsInteractive = true;
                while (!_isExit)
                {
                    PrintMenu();
                    Console.WriteLine("Press key in [] to perform command, Ctrl+Q to exit");
                    var keyInfo = Console.ReadKey();

                    if (ProcessCommand(keyInfo)) continue;

                    Console.Clear();
                    Console.WriteLine("Invalid Command. (Don't press any key modifiers for command)");
                    ToMainMenu();
                }
            }
            else
            {
                var options = new Options();
                if (!CommandLine.Parser.Default.ParseArguments(args, options)) return;
                IsInteractive = false;
                foreach (var cmd in _commands.Values.Where(cmd => cmd.IsRunnable(options)))
                {
                    cmd.Run();
                }
            }
        }