public static void main()

in rocketmq-connect-cli/src/main/java/org/apache/rocketmq/connect/cli/ConnectAdminStartup.java [62:134]


    public static void main(String[] args) {
        System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));

        String[] configArgs = Arrays.copyOfRange(args, 0, 2);
        args = Arrays.copyOfRange(args, 2, args.length);

        try {

            // Build the command line options.
            Options option = ServerUtil.buildCommandlineOptions(new Options());
            commandLine = ServerUtil.parseCmdLine("connect", configArgs, buildCommandlineOptions(option),
                    new PosixParser());
            if (null == commandLine) {
                System.exit(-1);
            }

            // Load configs from command line.
            Config config = new Config();
            if (commandLine.hasOption('s')) {
                String file = commandLine.getOptionValue('s');
                if (file != null) {
                    configFile = file;
                    InputStream in = new BufferedInputStream(new FileInputStream(file));
                    properties = new Properties();
                    properties.load(in);
                    FileAndPropertyUtil.properties2Object(properties, config);
                    in.close();
                }
            }

            initCommand(config);

            switch (args.length) {
                case 0:
                    printHelp();
                    break;
                case 2:
                    if (args[0].equals("help")) {
                        SubCommand cmd = findSubCommand(args[1]);
                        if (cmd != null) {
                            Options options = ServerUtil.buildCommandlineOptions(new Options());
                            options = cmd.buildCommandlineOptions(options);
                            if (options != null) {
                                ServerUtil.printCommandLineHelp("connectAdmin " + cmd.commandName(), options);
                            }
                        } else {
                            System.out.printf("The sub command %s not exist.%n", args[1]);
                        }
                        break;
                    }
                case 1:
                default:
                    SubCommand cmd = findSubCommand(args[0]);
                    if (cmd != null) {
                        String[] subargs = parseSubArgs(args);
                        Options options = ServerUtil.buildCommandlineOptions(new Options());
                        final CommandLine commandLine =
                                ServerUtil.parseCmdLine("connectAdmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options),
                                        new PosixParser());
                        if (null == commandLine) {
                            return;
                        }

                        cmd.execute(commandLine, options);
                    } else {
                        System.out.printf("The sub command %s not exist.%n", args[0]);
                    }
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }