Ejemplo n.º 1
0
		public int Run(string[] args)
		{
			CommandLineApplication 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())
				{
					CSharpRunner runner = new CSharpRunner();
					return runner.Run(Config.CSharp);
				}

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

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

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

			return app.Execute(args);
		}
Ejemplo n.º 2
0
        private static bool SetUp(string[] args)
        {
            CommandLineApplication result = new CommandLineApplication(false)
            {
                Name = "xpg",
                FullName = "XCommon Project Generator",
                Description = "Generate new C# project with support to Angular2 and Material Design",
            };

            var help = result.HelpOption("--help");
            var csharp = result.Option("--csharp", "Create new C# application", CommandOptionType.NoValue);
            var node = result.Option("--node", "Create new NODE application", CommandOptionType.NoValue);
            var angular = result.Option("--angular", "Create angular resource", CommandOptionType.NoValue);
            
            result.OnExecute(() =>
            {
                bool error = false;
                List<string> messages = new List<string>();

				if (angular.HasValue())
				{
					ApplicationBase.PrintLogo();
					var param = args.ToList();
					param.Remove("--angular");
					AngularRunner runner = new AngularRunner();
					return runner.Run(new AngularConfig(), param.ToArray());
				}

                if (!csharp.HasValue() && !node.HasValue())
                {
                    messages.Add("You need to chose which type of application you whant to create, use --node or --csharp");
                    error = true;
                }

                if (!csharp.HasValue() && !node.HasValue())
                {
                    messages.Add("You can't create both, choose --node or --csharp");
                    error = true;
                }

                if (!error && csharp.HasValue())
                {
                    App = new Application.CSharp.CSharpApplication(args);
                }

                if (!error && node.HasValue())
                {
                    App = new Application.Node.NodeApplication(args);
                }

                if (error)
                {
                    ApplicationBase.PrintLogo();

                    result.ShowHelp();
                    Console.WriteLine();
                    Console.WriteLine("  - Errors");
                    messages.ForEach(msg => Console.WriteLine($"    * {msg}"));
                    return -1;
                }

                return 0;
            });

            return result.Execute(args) == 0;
        }