Esempio n. 1
0
        private void ListAllCommands(HelpInput input)
        {
            if (!input.CommandTypes.Any())
            {
                Console.WriteLine("There are no known commands!");
                return;
            }

            var commands = input.CommandTypes.Select(type => new
            {
                Name        = CommandFactory.CommandNameFor(type),
                Description = CommandFactory.DescriptionFor(type)
            });

            var longestCommandName = commands
                                     .Select(m => m.Name)
                                     .Aggregate(string.Empty, (seed, f) => f?.Length > seed.Length ? f : seed);

            var padRight = longestCommandName.Length + 2;

            Console2.BreakLine();

            commands.OrderBy(m => m.Name).ForEach(m =>
            {
                Console2.Yellow(m.Name.PadRight(padRight));
                Console2.Write(m.Description);
                Console2.BreakLine();
            });

            Console2.BreakLine();
            Console2.Write("For a command usage, type: ");
            Console2.White("miru help <command>");
            Console2.BreakLine();
            Console2.BreakLine();
        }
Esempio n. 2
0
        public void Execute()
        {
            Console2.BreakLine();
            Console2.GreyLine($"Deleting folder {_newSolutionDir}");
            Console2.BreakLine();

            Directories.DeleteIfExists(_newSolutionDir);

            ExecuteShell($"miru new {SolutionName}", _workingDir);

            ExecuteShell("dotnet build --nologo", _newSolutionDir);

            ExecuteShell("miru assets:setup", _newSolutionDir);
            ExecuteShell("miru db:create", _newSolutionDir);
            ExecuteShell("miru db:create -e Test", _newSolutionDir);
            ExecuteShell("miru make:feature TopupNew Topups New", _newSolutionDir);
            ExecuteShell("miru make:entity Topup", _newSolutionDir);

            CopyFromSample(A.Path / "src" / SolutionName / "Database" / "Migrations" / "201911071845_CreateTopup.cs");
            CopyFromSample(A.Path / "src" / SolutionName / "Database" / "MongDbContext.cs");
            CopyFromSample(A.Path / "src" / SolutionName / "Features" / "Topups" / "New.cshtml");
            CopyFromSample(A.Path / "src" / SolutionName / "Features" / "Topups" / "TopupNew.cs");
            CopyFromSample(A.Path / "src" / SolutionName / "Domain" / "Topup.cs");

            CopyFromSample(A.Path / "tests" / $"{SolutionName}.Tests" / "Features" / "Topups" / "TopupNewTest.cs");
            CopyFromSample(A.Path / "tests" / $"{SolutionName}.PageTests" / "Pages" / "Topups" / "TopupNewPageTest.cs");

            ExecuteShell("dotnet build  --nologo", _newSolutionDir);
            ExecuteShell("miru test", _newSolutionDir);
            ExecuteShell("miru pagetest", _newSolutionDir);

            Console2.GreenLine("YES! ");
        }
Esempio n. 3
0
        public static void New(this Maker m, string name)
        {
            var newSolutionDir = A.Path(m.Solution.RootDir, name);

            ThrowIfNewDirectoryExist(newSolutionDir);

            Console.WriteLine();

            // root
            m.Directory();
            Console.WriteLine();

            var map = Maker.ReadEmbedded("_New.yml").FromYml <Dictionary <string, string> >();

            foreach (var(key, stub) in map)
            {
                // FIXME: Use same tokens replacement as m.Template
                var destination = key
                                  .Replace("Corpo.Skeleton", m.Solution.Name)
                                  .Replace("Skeleton", m.Solution.ShortName)
                                  .Replace('\\', Path.DirectorySeparatorChar);

                m.Template(stub, destination);
            }

            m.Template("appSettings-example.yml", A.Path("src") / name / "appSettings.Development.yml");
            m.Template("appSettings-example.yml", A.Path("src") / name / "appSettings.Test.yml");

            Console2.BreakLine();
            Console2.Line($"New solution created at:");
            Console2.BreakLine();
            Console2.GreenLine($"\t{m.Solution.RootDir}");
            Console2.BreakLine();
            Console2.GreenLine("Good luck!");
        }
Esempio n. 4
0
        public static void New(this Maker m, string name)
        {
            var newSolutionDir = A.Path(m.Solution.RootDir, name);

            ThrowIfNewDirectoryExist(newSolutionDir);

            Console.WriteLine();

            // root
            m.Directory();
            Console.WriteLine();

            var map = Maker.ReadEmbedded("_New.yml").FromYml <Dictionary <string, string> >();

            foreach (var(key, stub) in map)
            {
                var destination = key
                                  .Replace("Skeleton", name)
                                  .Replace('\\', Path.DirectorySeparatorChar);

                m.Template(stub, destination);
            }

            Console2.BreakLine();
            Console2.Line($"New solution created at:");
            Console2.BreakLine();
            Console2.GreenLine($"\t{m.Solution.RootDir}");
            Console2.BreakLine();
            Console2.GreenLine("Good luck!");
        }
Esempio n. 5
0
        public override bool Execute(Input input)
        {
            Console2.BreakLine();

            _maker.Migration(input.Name, table: input.TableFlag);

            return(true);
        }
Esempio n. 6
0
        public async Task Execute()
        {
            var make = new Maker(_solution);

            Console2.BreakLine();

            make.Query(In, Name, Action, "List");

            await Task.CompletedTask;
        }
Esempio n. 7
0
        public async Task Execute()
        {
            Console2.BreakLine();

            _maker.Migration(Name);

            Console2.BreakLine();

            await Task.CompletedTask;
        }
Esempio n. 8
0
        public override bool Execute(Input input)
        {
            var make = new Maker(_solution);

            Console2.BreakLine();

            make.Email(input.In, input.Name, input.Action);

            return(true);
        }
Esempio n. 9
0
            public async Task Execute()
            {
                var make = new Maker(_solution);

                Console2.BreakLine();

                make.Consolable(Name);

                Console2.BreakLine();

                await Task.CompletedTask;
            }
Esempio n. 10
0
            public Task Execute()
            {
                var maker = new Maker(_solution);

                Console2.BreakLine();

                maker.AppSettings(Environment);

                Console2.BreakLine();

                return(Task.CompletedTask);
            }
Esempio n. 11
0
        private void ExecuteShell(string command, string workingDir = null)
        {
            Console2.BreakLine();
            Console2.YellowLine($"Executing '{command}' at {workingDir.Or("Current directory")}");
            Console2.BreakLine();

            int ret = OS.ShellToConsole(command, workingDir);

            if (ret != 0)
            {
                Console2.RedLine($"Shell command returned code {ret}. Something went wrong. It should return 0");
                throw new Exception($"Shell command returned code {ret}");
            }
        }
Esempio n. 12
0
        public override bool Execute(Input input)
        {
            Console2.BreakLine();

            _maker.Entity(input.Name);

            Console2.BreakLine();

            Console2.GreyLine("\tConsider adding to your DbContext:");
            Console2.BreakLine();
            Console2.WhiteLine($"\t\tpublic DbSet<{input.Name}> {input.Name.Pluralize()} {{ get; set; }}");

            return(true);
        }
Esempio n. 13
0
        public override bool Execute(Input input)
        {
            var make = new Maker(_solution);

            Console2.BreakLine();

            make.FeatureAll(input.In, input.Name);

            Console2.BreakLine();
            Console2.WhiteLine($"Consider creating an Entity and a Migration for {input.Name}");
            Console2.BreakLine();

            return(true);
        }
Esempio n. 14
0
        public async Task Execute()
        {
            Console2.BreakLine();

            _maker.Entity(Name);

            Console2.BreakLine();

            Console2.GreyLine("\tConsider adding to your DbContext:");
            Console2.BreakLine();
            Console2.WhiteLine($"\t\tpublic DbSet<{Name}> {Name.Pluralize()} {{ get; set; }}");

            await Task.CompletedTask;
        }
Esempio n. 15
0
            public Task Execute()
            {
                var maker = new Maker(_solution);

                Console2.BreakLine();

                maker.Scaffold(In, Name);

                Console2.BreakLine();
                Console2.WhiteLine($"Consider creating an Entity and a Migration for {Name}");
                Console2.BreakLine();

                return(Task.CompletedTask);
            }
Esempio n. 16
0
        public override bool Execute(Input input)
        {
            var make = new Maker(_solution);

            Console2.BreakLine();

            if (input.Template.IsEmpty())
            {
                Console2.YellowLine("Choose one of the templates passing the flag:");
                Console2.WhiteLine("--new");
                Console2.WhiteLine("--show");
                Console2.WhiteLine("--list");
                Console2.WhiteLine("--edit");

                return(false);
            }

            make.Feature(input.In, input.Name, input.Action, input.Template);

            Console2.BreakLine();

            return(true);
        }