private void parseCommandLine()

in src/main/java/com/microsoft/azure/functions/worker/Application.java [24:68]


    private void parseCommandLine(String[] args) {
        CommandLineParser parser = new DefaultParser();
        try {
            CommandLine commands = parser.parse(this.OPTIONS, args, true);

            if (commands.hasOption("fu")) {
                this.uri = this.parseUri(commands.getOptionValue(FUNCTIONS_URI_OPTION));
            }else if (commands.hasOption("h") && commands.hasOption("p")) {
                this.host = this.parseHost(commands.getOptionValue("h"));
                this.port = this.parsePort(commands.getOptionValue("p"));
            }else {
                throw new ParseException("Error parsing command line options. Please include functions host and port or uri.");
            }

            if (commands.hasOption("fw")) {
                this.workerId = this.parseWorkerId(commands.getOptionValue(FUNCTIONS_WORKER_ID_OPTION));
            }else if (commands.hasOption("w")) {
                this.workerId = this.parseWorkerId(commands.getOptionValue("w"));
            }else {
                throw new ParseException("Error parsing command line options. Please include worker id.");
            }

            if (commands.hasOption("fq")) {
                this.requestId = this.parseRequestId(commands.getOptionValue(FUNCTIONS_REQUEST_ID_OPTION));
            }else if (commands.hasOption("q")) {
                this.requestId = this.parseRequestId(commands.getOptionValue("q"));
            }else {
                throw new ParseException("Error parsing command line options. Please include request id.");
            }

            this.logToConsole = commands.hasOption(FUNCTIONS_CONSOLE_LOG_OPTION) || commands.hasOption("l");

            if (commands.hasOption(FUNCTIONS_GRPC_MAX_MESSAGE_LENGTH_OPTION)) {
                this.maxMessageSize = this.parseMaxMessageSize(commands.getOptionValue(FUNCTIONS_GRPC_MAX_MESSAGE_LENGTH_OPTION));
            } else if (commands.hasOption("m")) {
                this.maxMessageSize = this.parseMaxMessageSize(commands.getOptionValue("m"));
            }else {
                throw new ParseException("Error parsing command line options. Please include message size in bytes.");
            }
            this.commandParseSucceeded = true;
        } catch (ParseException ex) {
            WorkerLogManager.getSystemLogger().severe(ex.toString());
            this.commandParseSucceeded = false;
        }
    }