public static int run(String[] args) {
        BrokerTool brokerTool = new BrokerTool();
        CommandLine commander = new CommandLine(brokerTool);
        GenerateDocsCommand generateDocsCommand = new GenerateDocsCommand(commander);
        commander.addSubcommand(LoadReportCommand.class)
                .addSubcommand(generateDocsCommand);
        return commander.execute(args);
    }
@Test
    public void testGenerateDocs() throws Exception {
        PrintStream oldStream = System.out;
        try {
            ByteArrayOutputStream baoStream = new ByteArrayOutputStream();
            System.setOut(new PrintStream(baoStream));

            BrokerTool.run(new String[]{"gen-doc"});

            String message = baoStream.toString();

            Class argumentsClass = Class.forName("org.apache.pulsar.broker.tools.LoadReportCommand");
            Field[] fields = argumentsClass.getDeclaredFields();
            for (Field field : fields) {
                boolean fieldHasAnno = field.isAnnotationPresent(Option.class);
                if (fieldHasAnno) {
                    Option fieldAnno = field.getAnnotation(Option.class);
                    String[] names = fieldAnno.names();
                    String nameStr = Arrays.asList(names).toString();
                    nameStr = nameStr.substring(1, nameStr.length() - 1);
                    assertTrue(message.indexOf(nameStr) > 0);
                }
            }
        } finally {
            System.setOut(oldStream);
        }
    }