Ejemplo n.º 1
0
        public static void ProcessCommand(string[] args)
        {
            var command  = new string[0];
            var tryParse = false;

            if (args?.Length != 0)
            {
                command  = args;
                tryParse = true;
            }
            var initialInput = new CommandInput(command);
            var isValid      = false;

            if (tryParse)
            {
                isValid = initialInput.Parse();
            }
            if (tryParse && !isValid && args != null)
            {
                var argument = string.Join(" ", args);
                Console.WriteLine($"Ошибка распознания аргументов: `{argument}`");
            }
            var isSuccess = false;

            if (isValid)
            {
                var handler          = new Manager(initialInput).getHandler();
                var databaseFilePath = Properties.Settings.Default?.DataPath;
                isSuccess = handler != null && handler.Execute(databaseFilePath);
            }
            if (isValid && !isSuccess && args != null)
            {
                var argument = string.Join(" ", args);
                Console.WriteLine($"Ошибка выполнения команды: `{argument}`");
            }
            if (isValid && isSuccess && args != null)
            {
                var argument = string.Join(" ", args);
                Console.WriteLine($"Команда `{argument}` выполнена успешно");
            }
        }
Ejemplo n.º 2
0
 public Update(CommandInput command) : base(command)
 {
 }
Ejemplo n.º 3
0
 public Mount(CommandInput command) : base(command)
 {
 }
 protected CommandHandler(CommandInput command)
 {
     Command = command;
 }