Ejemplo n.º 1
0
        public int Run(string[] args)
        {
            var app = new CommandLineApplication(false)
            {
                Name        = "Prospect code generator",
                Description = "Runs different methods as dnx commands to help you to create some of picies of code",
            };

            var help       = app.HelpOption("-?|--help");
            var csharp     = app.Option("-c|--csharp", "C# code generarion", CommandOptionType.NoValue);
            var typeScript = app.Option("-t|--typescript", "TypeScript code generarion", CommandOptionType.NoValue);

            CustomRunners.ForEach(item =>
            {
                item.Command = app.Option($"-{item.TemplateShort}|--{item.TemplateLong}", item.Description, CommandOptionType.NoValue);
            });

            app.OnExecute(() =>
            {
                if (csharp.HasValue())
                {
                    Runner = new CSharpRunner();
                    return(Runner.Run());
                }

                if (typeScript.HasValue())
                {
                    Runner = new TypeScriptRunner();
                    return(Runner.Run());
                }

                foreach (var item in CustomRunners)
                {
                    if (item.Command.HasValue())
                    {
                        Runner = (BaseRunner)Activator.CreateInstance(item.RunnerType);
                        return(Runner.Run());
                    }
                }

                app.ShowHelp();
                return(0);
            });

            return(app.Execute(args));
        }
Ejemplo n.º 2
0
        public int Run(string[] args)
        {
            var app = new CommandLineApplication(false)
            {
                Name        = "Prospect code generator",
                Description = "Runs different methods as dnx commands to help you to create some of picies of code",
            };

            var help       = app.HelpOption("-?|--help");
            var angular    = app.Option("-a|--angular", "Angular code generation", CommandOptionType.NoValue);
            var csharp     = app.Option("-c|--csharp", "C# code generarion", CommandOptionType.NoValue);
            var typeScript = app.Option("-t|--typescript", "TypeScript code generarion", CommandOptionType.NoValue);

            app.OnExecute(() => {
                if (csharp.HasValue())
                {
                    var runner = new CSharpRunner();
                    return(runner.Run());
                }

                if (angular.HasValue())
                {
                    var runner = new AngularRunner();
                    return(runner.Run(args));
                }

                if (typeScript.HasValue())
                {
                    var runner = new TypeScriptRunner();
                    return(runner.Run());
                }

                app.ShowHelp();
                return(0);
            });

            return(app.Execute(args));
        }