コード例 #1
0
        public static void Main(string[] args)
        {
            /* TODO use command argument processor for every command so we can figure out what the user wants to do
             * CliArgumentProcessor argumentProcessor = new CliArgumentProcessor(args, new CliArgumentOption() { Name = "port", ExpectedValueType = CliArgumentOptionValueType.Integer },
             *  new CliArgumentOption { Name = "yes", ExpectedValueType = CliArgumentOptionValueType.None });
             * argumentProcessor.CatchUnknownOptions = true;
             * argumentProcessor.Error += ArgumentProcessor_Error;
             * argumentProcessor.ParseArguments();*/
            CommandRegistry reg = new CommandRegistry(new CommandAbout(), new CommandHelp(), new CommandStart(), new CommandEditCfg());

            if (args.Length < 1)
            {
                ConsoleExtensions.WriteLineError("Error: No command specified, run \"{0}\" for a list of available commands.", "fasthttps --help");
                return;
            }
            CommandResult res = reg.ExecuteCommandByName(args[0], args);

            if (res.ExitCode == 255)
            {
                ConsoleExtensions.WriteLineError("Error: \"{0}\" is not a valid command, try \"fasthttps --help\" for help.", args[0]);
            }
            Environment.Exit(res.ExitCode);
        }