Exemple #1
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                PrintUsageHeader();
                PrintUsage();
                Environment.Exit(-1);
            }

            ICommand command = null;

            switch (args[0])
            {
            case StartElectronCommand.COMMAND_NAME:
                command = new StartElectronCommand(args.Skip(1).ToArray());
                break;

            case BuildCommand.COMMAND_NAME:
                command = new BuildCommand(args.Skip(1).ToArray());
                break;

            case InitCommand.COMMAND_NAME:
                command = new InitCommand(args.Skip(1).ToArray());
                break;

            case VersionCommand.COMMAND_NAME:
                command = new VersionCommand(args.Skip(1).ToArray());
                break;

            case "--help":
            case "--h":
            case "help":
                PrintUsageHeader();

                if (args.Length > 1)
                {
                    PrintUsage(args[1]);
                }
                else
                {
                    PrintUsage();
                }
                break;

            default:
                Console.Error.WriteLine($"Unknown command {args[0]}");
                PrintUsage();
                Environment.Exit(-1);
                break;
            }

            if (command != null)
            {
                var success = command.ExecuteAsync().Result;
                if (!success)
                {
                    Environment.Exit(-1);
                }
            }
        }
Exemple #2
0
        static async Task Main(string[] args)
        {
            if (args.Length == 0)
            {
                PrintUsageHeader();
                PrintUsage();
                Environment.Exit(-1);
            }

            Console.CancelKeyPress += (s, e) =>
            {
                ProcessHelper.KillActive();
                Environment.Exit(-1);
            };

            ICommand command = null;

            switch (args[0])
            {
            case StartElectronCommand.COMMAND_NAME:
                command = new StartElectronCommand(args.Skip(1).ToArray());
                break;

            case BuildCommand.COMMAND_NAME:
                command = new BuildCommand(args.Skip(1).ToArray());
                break;

            case InitCommand.COMMAND_NAME:
                command = new InitCommand(args.Skip(1).ToArray());
                break;

            case AddCommand.COMMAND_NAME:
                command = new AddCommand(args.Skip(1).ToArray());
                break;

            case VersionCommand.COMMAND_NAME:
                command = new VersionCommand();
                break;

            case "--help":
            case "--h":
            case "help":
                PrintUsageHeader();

                if (args.Length > 1)
                {
                    PrintUsage(args[1]);
                }
                else
                {
                    PrintUsage();
                }
                break;

            default:
                Console.Error.WriteLine($"Unknown command {args[0]}");
                PrintUsage();
                Environment.Exit(-1);
                break;
            }

            if (command != null)
            {
                var success = await command.ExecuteAsync();

                if (!success)
                {
                    Environment.Exit(-1);
                }
            }
        }