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}` выполнена успешно");
            }
        }
 public Update(CommandInput command) : base(command)
 {
 }
Esempio n. 3
0
 public Mount(CommandInput command) : base(command)
 {
 }
 protected CommandHandler(CommandInput command)
 {
     Command = command;
 }