Ejemplo n.º 1
0
        public static void Run(string buildSolutionDirectory, IFileSystem fileSystem)
        {
            try
            {
                var promptResponse = RunPrompt();
                var templateString = GetExampleDomain(promptResponse.name, promptResponse.type);

                var domainProject   = FileParsingHelper.ReadYamlString <DomainProject>(templateString);
                var domainDirectory = $"{buildSolutionDirectory}{Path.DirectorySeparatorChar}{domainProject.DomainName}";

                NewDomainProjectCommand.CreateNewDomainProject(domainDirectory, fileSystem, domainProject);
                ExampleTemplateBuilder.CreateYamlFile(domainDirectory, templateString, fileSystem);

                AnsiConsole.MarkupLine($"{Environment.NewLine}[bold yellow1]Your example project is project is ready![/]");
                StarGithubRequest();
            }
            catch (Exception e)
            {
                if (e is FileAlreadyExistsException ||
                    e is DirectoryAlreadyExistsException ||
                    e is InvalidSolutionNameException ||
                    e is FileNotFoundException ||
                    e is InvalidDbProviderException ||
                    e is InvalidFileTypeException ||
                    e is DataValidationErrorException ||
                    e is SolutiuonNameEntityMatchException)
                {
                    WriteError($"{e.Message}");
                }
                else
                {
                    AnsiConsole.WriteException(e, new ExceptionSettings
                    {
                        Format = ExceptionFormats.ShortenEverything | ExceptionFormats.ShowLinks,
                        Style  = new ExceptionStyle
                        {
                            Exception     = new Style().Foreground(Color.Grey),
                            Message       = new Style().Foreground(Color.White),
                            NonEmphasized = new Style().Foreground(Color.Cornsilk1),
                            Parenthesis   = new Style().Foreground(Color.Cornsilk1),
                            Method        = new Style().Foreground(Color.Red),
                            ParameterName = new Style().Foreground(Color.Cornsilk1),
                            ParameterType = new Style().Foreground(Color.Red),
                            Path          = new Style().Foreground(Color.Red),
                            LineNumber    = new Style().Foreground(Color.Cornsilk1),
                        }
                    });
                }
            }
        }