static void Main(string[] args) { //var argsV2 = StringFormats.StringToParams(string.Join(" ", args)); _loggerService = new LoggerService(); _loggerService.Log("###### INITIALIZED DYNAMICS CLI ######"); LogRecievedArgs(args); bool isRecursive = args.Any(k => k.Length > 0 && k.First() == '\"'); var argsV2 = isRecursive ? StringFormats.StringToParams(string.Join(" ", args)) : args; LogProcessedArgs(argsV2); var storedData = StoredDataManager.GetStoredData(); _loggerService = new LoggerService(); IRegistryService registryService = new RegistryService(); ICryptoService cryptoService = new CryptoService(registryService); IStoredDataService storedDataService = new StoredDataService(storedData, cryptoService); commandManager = new CommandManager(_loggerService, storedDataService, cryptoService); commandManager.OnLog += CommandManager_OnLog; RegisterCommands(storedDataService, registryService, cryptoService); try { var inputCommand = new InputRequest(argsV2); commandManager.ExecuteInputRequest(inputCommand); } catch (PathNotFoundException ex) { ExceptionManager.RaiseException(_loggerService, $"Path '{ex.Message}' does not exists"); } catch (Exception ex) { ExceptionManager.RaiseException(_loggerService, $"Throwed uncatched exception: {ex.ToString()}"); } }
private void SaveContext() { StoredDataManager.SaveStoredCliData(StoredCliData); }
public T GetStoredData() { return(StoredDataManager.GetStoredData <T>(GetFilePath())); }
public void SaveStoredData(T data) { StoredDataManager.SaveStoredData <T>(GetFilePath(), data); }
static void Main(string[] args) { _loggerService = new LoggerService(); _loggerService.Log("###### INITIALIZED CLI ######"); LogRecievedArgs(args); bool isRecursive = args.Any(k => k.Length > 0 && k.First() == '\"'); var argsV2 = isRecursive ? StringFormats.StringToParams(string.Join(" ", args)) : args; LogProcessedArgs(argsV2); var storedData = StoredDataManager.GetStoredData(); IRegistryService registryService = new RegistryService(); ICryptoService cryptoService = new CryptoService(registryService); IStoredDataService storedDataService = new StoredDataService(storedData, cryptoService); commandManager = new CommandManager(_loggerService, storedDataService, cryptoService); commandManager.OnLog += CommandManager_OnLog; RegisterCommands(storedDataService, registryService, cryptoService); try { var inputCommand = new InputRequest(argsV2); commandManager.ExecuteInputRequest(inputCommand); } catch (DuplicateCommandException ex) { ExceptionManager.RaiseException(_loggerService, $"Found {ex.Commands.Count} commands with the same name in different namespaces. In this case is necessary use the namespace for execute it. Commands: {string.Join(",", ex.Commands.ToArray())}"); } catch (CommandNotFoundException) { ExceptionManager.RaiseException(_loggerService, $"Command not found. Use 'help' for check the available commands"); } catch (InvalidParamsException) { ExceptionManager.RaiseException(_loggerService, $"This command cannot be executed with this combination of parameters"); } catch (InvalidParamNameException ex) { ExceptionManager.RaiseException(_loggerService, $"Invalid parameter name '{ex.Message}'"); } catch (NotArgumentsException) { ExceptionManager.RaiseException(_loggerService, $"Check all the params with 'help' command"); } catch (NotValidCommandNameException ex) { ExceptionManager.RaiseException(_loggerService, $"Invalid command name '{ex.Message}'"); } catch (AliasRepeatedException ex) { ExceptionManager.RaiseException(_loggerService, $"Alias '{ex.Message}' is already used"); } catch (AliasNotFoundException ex) { ExceptionManager.RaiseException(_loggerService, $"Alias '{ex.Message}' is not registered"); } catch (ParameterRepeatedException ex) { ExceptionManager.RaiseException(_loggerService, $"Parameter '{ex.Message}' is already used"); } catch (ParameterNotFoundException ex) { ExceptionManager.RaiseException(_loggerService, $"Parameter '{ex.Message}' is not registered"); } catch (InvalidParamException ex) { ExceptionManager.RaiseException(_loggerService, $"Cannot resolver parameter {ex.Message}"); } catch (PathNotFoundException ex) { ExceptionManager.RaiseException(_loggerService, $"Path '{ex.Message}' does not exists"); } catch (TemplateConfigFileNotFoundException) { ExceptionManager.RaiseException(_loggerService, $"Can't find '{Definitions.TemplateConfigFilename}' file in path"); } catch (InvalidTemplateConfigFileException ex) { ExceptionManager.RaiseException(_loggerService, $"Config file '{Definitions.TemplateConfigFilename}' is invalid. Error parsing: {ex.Message}"); } catch (InvalidStringFormatException ex) { ExceptionManager.RaiseException(_loggerService, $"Invalid string format. {ex.Message}"); } catch (TemplateNameRepeatedException) { ExceptionManager.RaiseException(_loggerService, $"Template name repeated"); } catch (TemplateNotFoundException) { ExceptionManager.RaiseException(_loggerService, $"Can't find any template with this name"); } catch (RepositoryNotFoundException) { ExceptionManager.RaiseException(_loggerService, $"Can't find any repository with this name"); } catch (PipelineConfigFileNotFoundException) { ExceptionManager.RaiseException(_loggerService, $"Can't find '{Definitions.PipelineConfigFilename}' file in path"); } catch (InvalidPipelineConfigFileException ex) { ExceptionManager.RaiseException(_loggerService, $"Config file '{Definitions.PipelineConfigFilename}' is invalid. Error parsing: {ex.Message}"); } catch (PipelineNameRepeatedException) { ExceptionManager.RaiseException(_loggerService, $"Pipeline name repeated"); } catch (PipelineNotFoundException) { ExceptionManager.RaiseException(_loggerService, $"Can't find any pipeline with this name"); } catch (Exception ex) { ExceptionManager.RaiseException(_loggerService, $"Throwed uncatched exception: {ex.ToString()}"); } finally { _loggerService.Log("###### FINISHED! ######"); } }