public static int doMain(String[] args) throws Exception {
        Arguments arguments = new Arguments();
        CommandLine commander = new CommandLine(arguments);
        try {
            commander.parseArgs(args);
            if (arguments.help) {
                commander.usage(commander.getOut());
                return 0;
            }
            if (arguments.generateDocs) {
                CmdGenerateDocs cmd = new CmdGenerateDocs("pulsar");
                cmd.addCommand("initialize-namespace", commander);
                cmd.run(null);
                return 0;
            }
        } catch (Exception e) {
            commander.getErr().println(e);
            return 1;
        }

        if (arguments.configurationStore == null) {
            System.err.println("Configuration store address argument is required (--configuration-store)");
            commander.usage(commander.getOut());
            return 1;
        }

        try (MetadataStore configStore = PulsarClusterMetadataSetup
                .initConfigMetadataStore(arguments.configurationStore, arguments.zkSessionTimeoutMillis)) {
            PulsarResources pulsarResources = new PulsarResources(null, configStore);
            for (String namespace : arguments.namespaces) {
                NamespaceName namespaceName = null;
                try {
                    namespaceName = NamespaceName.get(namespace);
                } catch (Exception e) {
                    System.out.println("Invalid namespace name.");
                    return 1;
                }

                // Create specified tenant
                PulsarClusterMetadataSetup
                        .createTenantIfAbsent(pulsarResources, namespaceName.getTenant(), arguments.cluster);

                // Create specified namespace
                PulsarClusterMetadataSetup.createNamespaceIfAbsent(pulsarResources, namespaceName,
                        arguments.cluster);
            }
        }

        System.out.println("Initial namespace setup success");
        return 0;
    }
@Test
    public void testMainGenerateDocs() throws Exception {
        PrintStream oldStream = System.out;
        try {
            ByteArrayOutputStream baoStream = new ByteArrayOutputStream();
            System.setOut(new PrintStream(baoStream));

            Class argumentsClass =
                    Class.forName("org.apache.pulsar.PulsarInitialNamespaceSetup$Arguments");

            PulsarInitialNamespaceSetup.doMain(new String[]{"-cs", "cs", "-c", "c", "-g", "demo"});

            String message = baoStream.toString();

            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();
                    if (names.length == 0) {
                        continue;
                    }
                    String nameStr = Arrays.asList(names).toString();
                    nameStr = nameStr.substring(1, nameStr.length() - 1);
                    assertTrue(message.indexOf(nameStr) > 0);
                }
            }
        } finally {
            System.setOut(oldStream);
        }
    }