private static void Main(string[] args) { try { if (args == null || args.Length == 0 || _consoleArgsReader.ContainsHelpParam(args)) { ShowHelp(); return; } if (_consoleArgsReader.ContainsGetCwdParam(args)) { string cwd = _fileSystem.GetCurrentDirectory(); _logger.Log($"Current working directory is: {cwd}"); return; } bool verbose = _consoleArgsReader.ContainsVerboseParam(args); string[] projectFolders = _consoleArgsReader.GetProjectFolders(args).ToArray(); string[] configPaths = _consoleArgsReader.GetConfigPaths(args).ToArray(); for (var i = 0; i < projectFolders.Length; i++) { string projectFolder = projectFolders[i]; string configPath = configPaths.HasIndex(i) ? configPaths[i] : null; _assemblyResolver = new AssemblyResolver(_fileSystem, projectFolder); _logger.Log($"Generating files for project \"{projectFolder}\"..."); Generate(projectFolder, configPath, verbose); _logger.Log($"Files for project \"{projectFolder}\" generated successfully.", ""); } } catch (Exception e) when(e is CliException || e is CoreException) { _logger.Log($"APPLICATION ERROR: {e.Message}", e.StackTrace); } catch (AssemblyResolutionException e) { string message = e.Message + "Consider adding any external assembly directories in the externalAssemblyPaths parameter. " + "If you're using ASP.NET Core, add your NuGet directory to externalAssemblyPaths parameter (you can use global NuGet packages directory alias: \"<global-packages>\")"; _logger.Log(message, e.StackTrace); } catch (ReflectionTypeLoadException e) { foreach (Exception loaderException in e.LoaderExceptions) { _logger.Log($"TYPE LOAD ERROR: {loaderException.Message}", e.StackTrace); } } catch (Exception e) { _logger.Log($"GENERIC ERROR: {e.Message}", e.StackTrace); } }
public void ContainsGetCwdParam_Test(string[] args, bool expectedResult) { bool actualResult = _consoleArgsReader.ContainsGetCwdParam(args); Assert.Equal(expectedResult, actualResult); }