Example usage for org.apache.commons.cli HelpFormatter setSyntaxPrefix

List of usage examples for org.apache.commons.cli HelpFormatter setSyntaxPrefix

Introduction

In this page you can find the example usage for org.apache.commons.cli HelpFormatter setSyntaxPrefix.

Prototype

public void setSyntaxPrefix(String prefix) 

Source Link

Document

Sets the 'syntaxPrefix'.

Usage

From source file:org.codeseed.common.config.ext.CommandLineHelper.java

/**
 * Returns a property source from the supplied command line arguments.
 *
 * @param args// w ww  .ja  v  a  2s .co  m
 *            the arguments passed from the command line
 * @return a property source backed by the parsed command line arguments
 */
public PropertySource parse(String[] args) {
    // Construct the command line options
    final Options options = this.options.build();
    if (helpOption != null) {
        options.addOption(helpOption);
    }

    try {
        final CommandLine commandLine = parser.parse(options, args);
        if (helpOption != null && commandLine.hasOption(helpOption.getOpt())) {
            // Display the help
            HelpFormatter help = new HelpFormatter();
            help.setSyntaxPrefix(syntaxPrefix());
            help.setLongOptPrefix(" --");
            help.printHelp(err, terminalWidth, applicationName(), header(), options, 1, 1, footer(), true);
            return helpExit();
        } else {
            // Wrapped the parsed commands in a property source
            return new CommandLinePropertySource(commandLine);
        }
    } catch (ParseException e) {
        // Display the error and usage message
        HelpFormatter help = new HelpFormatter();
        help.printWrapped(err, terminalWidth, e.getMessage());
        help.printUsage(err, terminalWidth, applicationName(), options);
        throw usageExit(e);
    }
}

From source file:org.languagetool.dev.dumpcheck.SentenceSourceChecker.java

private static CommandLine ensureCorrectUsageOrExit(String[] args) {
    Options options = new Options();
    options.addOption(Option.builder("l").longOpt("language").argName("code").hasArg()
            .desc("language code like 'en' or 'de'").required().build());
    options.addOption(Option.builder("d").longOpt("db-properties").argName("file").hasArg()
            .desc("A file to set database access properties. If not set, the output will be written to STDOUT. "
                    + "The file needs to set the properties dbUrl ('jdbc:...'), dbUser, and dbPassword. "
                    + "It can optionally define the batchSize for insert statements, which defaults to 1.")
            .build());/*from w w w. ja  v  a  2  s. com*/
    options.addOption(Option.builder().longOpt("rule-properties").argName("file").hasArg().desc(
            "A file to set rules which should be disabled per language (e.g. en=RULE1,RULE2 or all=RULE3,RULE4)")
            .build());
    options.addOption(Option.builder("r").longOpt("rule-ids").argName("id").hasArg()
            .desc("comma-separated list of rule-ids to activate").build());
    options.addOption(Option.builder().longOpt("also-enable-categories").argName("categories").hasArg()
            .desc("comma-separated list of categories to activate, additionally to rules activated anyway")
            .build());
    options.addOption(Option.builder("f").longOpt("file").argName("file").hasArg().desc(
            "an unpacked Wikipedia XML dump; (must be named *.xml, dumps are available from http://dumps.wikimedia.org/backup-index.html) "
                    + "or a Tatoeba CSV file filtered to contain only one language (must be named tatoeba-*). You can specify this option more than once.")
            .required().build());
    options.addOption(Option.builder().longOpt("max-sentences").argName("number").hasArg()
            .desc("maximum number of sentences to check").build());
    options.addOption(Option.builder().longOpt("max-errors").argName("number").hasArg()
            .desc("maximum number of errors, stop when finding more").build());
    options.addOption(Option.builder().longOpt("languagemodel").argName("indexDir").hasArg()
            .desc("directory with a '3grams' sub directory that contains an ngram index").build());
    options.addOption(Option.builder().longOpt("neuralnetworkmodel").argName("baseDir").hasArg()
            .desc("base directory for saved neural network models").build());
    options.addOption(Option.builder().longOpt("filter").argName("regex").hasArg()
            .desc("Consider only sentences that contain this regular expression (for speed up)").build());
    try {
        CommandLineParser parser = new DefaultParser();
        return parser.parse(options, args);
    } catch (ParseException e) {
        System.err.println("Error: " + e.getMessage());
        HelpFormatter formatter = new HelpFormatter();
        formatter.setWidth(80);
        formatter.setSyntaxPrefix("Usage: ");
        formatter.printHelp(
                SentenceSourceChecker.class.getSimpleName() + " [OPTION]... --file <file> --language <code>",
                options);
        System.exit(1);
    }
    throw new IllegalStateException();
}

From source file:org.languagetool.dev.wikipedia.CheckWikipediaDump.java

@SuppressWarnings("AccessStaticViaInstance")
private static CommandLine ensureCorrectUsageOrExit(String[] args) {
    Options options = new Options();
    options.addOption(OptionBuilder.withLongOpt("language").withArgName("code").hasArg()
            .withDescription("language code like 'en' or 'de'").isRequired().create("l"));
    options.addOption(OptionBuilder.withLongOpt("db-properties").withArgName("file").hasArg().withDescription(
            "A file to set database access properties. If not set, the output will be written to STDOUT. "
                    + "The file needs to set dbDriver (fully qualified driver class), dbUrl ('jdbc:...'), dbUser, and dbPassword.")
            .create("d"));
    options.addOption(OptionBuilder.withLongOpt("rule-properties").withArgName("file").hasArg().withDescription(
            "A file to set rules which should be disabled per language (e.g. en=RULE1,RULE2 or all=RULE3,RULE4)")
            .create());/*from  www .ja  va 2s.  c o  m*/
    options.addOption(OptionBuilder.withLongOpt("rule-ids").withArgName("id").hasArg()
            .withDescription("comma-separated list of rule-ids to activate").create("r"));
    options.addOption(OptionBuilder.withLongOpt("file").withArgName("xmlfile").hasArg().withDescription(
            "an unpacked Wikipedia XML dump; dumps are available from http://dumps.wikimedia.org/backup-index.html")
            .isRequired().create("f"));
    options.addOption(OptionBuilder.withLongOpt("max-articles").withArgName("number").hasArg()
            .withDescription("maximum number of articles to check").create());
    options.addOption(OptionBuilder.withLongOpt("max-errors").withArgName("number").hasArg()
            .withDescription("maximum number of errors, stop when finding more").create());
    try {
        CommandLineParser parser = new GnuParser();
        return parser.parse(options, args);
    } catch (org.apache.commons.cli.ParseException e) {
        System.err.println("Error: " + e.getMessage());
        HelpFormatter formatter = new HelpFormatter();
        formatter.setWidth(80);
        formatter.setSyntaxPrefix("Usage: ");
        formatter.printHelp(
                CheckWikipediaDump.class.getSimpleName() + " [OPTION]... --file <xmlfile> --language <code>",
                options);
        System.exit(1);
    }
    return null;
}

From source file:org.mitre.secretsharing.cli.cmd.RootCommand.java

@Override
public void showHelp(PrintStream out) {
    super.showHelp(out);

    out.println();/* ww w  .  ja  v a  2  s  .  com*/

    Options cmds = new Options();
    for (Command c : Commands.subCommands()) {
        cmds.addOption(null, c.getName(), false, c.getDescription());
    }

    HelpFormatter h = new HelpFormatter();
    h.setSyntaxPrefix("");
    h.setLongOptPrefix("");
    h.setOptionComparator(new Comparator<Option>() {
        @Override
        public int compare(Option o1, Option o2) {
            Integer p1 = Commands.names().indexOf(o1.getLongOpt());
            Integer p2 = Commands.names().indexOf(o2.getLongOpt());
            return p1.compareTo(p2);
        }
    });
    h.printHelp(new PrintWriter(out, true), 80, "Valid Commands:", "", cmds, 12, 12, getActualHelpFooter());
    out.flush();
}

From source file:org.nuxeo.launcher.NuxeoLauncher.java

public static void printShortHelp() {
    HelpFormatter help = new HelpFormatter();
    help.setSyntaxPrefix("Usage: ");
    help.printHelp("nuxeoctl [options] <command> [command parameters]", launcherOptions);
}

From source file:org.ovirt.api.metamodel.tool.EnumGenerationToolJaxb.java

protected CommandLine createCommandLineOptions(String[] args) {
    // Create the command line options:
    Options options = new Options();

    options.addOption(Option.builder().longOpt(MODEL_OPTION)
            .desc("The directory or .jar file containing the source model files.").type(File.class)
            .required(true).hasArg(true).argName("DIRECTORY|JAR").build());

    options.addOption(Option.builder().longOpt(XJC_OPTION)
            .desc("The directory where the generated model classes will be created.").type(File.class)
            .required(false).hasArg(true).argName("DIRECTORY").build());

    // Parse the command line:
    CommandLineParser parser = new DefaultParser();
    CommandLine line = null;//from ww w  .  ja v  a 2s.co  m
    try {
        line = parser.parse(options, args);
    } catch (ParseException exception) {
        System.out.println(exception);
        HelpFormatter formatter = new HelpFormatter();
        formatter.setSyntaxPrefix("Usage: ");
        formatter.printHelp("enum-generation--tool [OPTIONS]", options);
        System.exit(1);
    }
    return line;
}

From source file:org.ovirt.api.metamodel.tool.Tool.java

public void run(String[] args) throws Exception {
    // Create the command line options:
    Options options = new Options();

    // Options for the locations of files and directories:
    options.addOption(Option.builder().longOpt(MODEL_OPTION)
            .desc("The directory or .jar file containing the source model files.").type(File.class)
            .required(true).hasArg(true).argName("DIRECTORY|JAR").build());

    // Options for the location of the generated XML and JSON model representations:
    options.addOption(Option.builder().longOpt(XML_DESCRIPTION_OPTION)
            .desc("The location of the generated XML description of the model. If not specified then the XML "
                    + "description isn't generated.")
            .type(File.class).required(false).hasArg(true).argName("FILE").build());
    options.addOption(Option.builder().longOpt(JSON_DESCRIPTION_OPTION)
            .desc("The location of the generated JSON description of the model. If not specified then the JSON "
                    + "description isn't generated.")
            .type(File.class).required(false).hasArg(true).argName("FILE").build());

    // Options for the location of the input and output XML schemas:
    options.addOption(Option.builder().longOpt(IN_SCHEMA_OPTION).desc("The XML schema input file.")
            .type(File.class).required(false).hasArg(true).argName("FILE").build());
    options.addOption(Option.builder().longOpt(OUT_SCHEMA_OPTION).desc("The XML schema output file.")
            .type(File.class).required(false).hasArg(true).argName("FILE").build());

    // Options for the names of generated Java sources:
    options.addOption(Option.builder().longOpt(JAVA_OPTION)
            .desc("The directory where the generated Java source will be created.").type(File.class)
            .required(false).hasArg(true).argName("DIRECTORY").build());
    options.addOption(Option.builder().longOpt(JAXRS_OPTION)
            .desc("The directory where the generated JAX-RS source will be created.").type(File.class)
            .required(false).hasArg(true).argName("DIRECTORY").build());
    options.addOption(Option.builder().longOpt(JAXRS_PACKAGE_OPTION)
            .desc("The name of the Java package for JAX-RS interfaces.").required(false).hasArg(true)
            .argName("PACKAGE").build());
    options.addOption(Option.builder().longOpt(XJC_PACKAGE_OPTION)
            .desc("The name of the Java package for classes generated by the XJC compiler.").required(false)
            .hasArg(true).argName("PACKAGE").build());
    options.addOption(Option.builder().longOpt(TYPES_PACKAGE_OPTION)
            .desc("The name of the Java package for the generated type interfaces.").required(false)
            .hasArg(true).argName("PACKAGE").build());
    options.addOption(Option.builder().longOpt(CONTAINERS_PACKAGE_OPTION)
            .desc("The name of the Java package for the generated type containers.").required(false)
            .hasArg(true).argName("PACKAGE").build());
    options.addOption(Option.builder().longOpt(BUILDERS_PACKAGE_OPTION)
            .desc("The name of the Java package for the generated type builders.").required(false).hasArg(true)
            .argName("PACKAGE").build());
    options.addOption(Option.builder().longOpt(JSON_PACKAGE_OPTION)
            .desc("The name of the Java package for the generated JSON readers and writers.").required(false)
            .hasArg(true).argName("PACKAGE").build());
    options.addOption(Option.builder().longOpt(XML_PACKAGE_OPTION)
            .desc("The name of the Java package for the generated XML readers and writers.").required(false)
            .hasArg(true).argName("PACKAGE").build());
    options.addOption(Option.builder().longOpt(VERSION_PREFIX_OPTION)
            .desc("The version prefix to add to the generated Java class names, for example V4.")
            .required(false).hasArg(true).argName("PREFIX").build());

    // Options for the generation of documentation:
    options.addOption(Option.builder().longOpt(DOCS_OPTION)
            .desc("The directory where the generated documentation will be created.").type(File.class)
            .required(false).hasArg(true).argName("DIRECTORY").build());
    options.addOption(Option.builder().longOpt(ADOC_ATTRIBUTE_OPTION).desc(
            "An attribute to be included in the generated AsciiDoc documentation. The value of the argument "
                    + "should be the name attribute, followed by an optional colon and the value of the attribute.")
            .required(false).hasArg(true).argName("ATTRIBUTE").build());
    options.addOption(Option.builder().longOpt(ADOC_SEPARATOR_OPTION)
            .desc("The character to use as the separator of section identifiers in the generated AsciiDoc "
                    + "documentation. If not specified the forward slash character will be used.")
            .required(false).hasArg(true).argName("SEPARATOR").build());
    options.addOption(/*from w  w  w  . j  ava  2s .  co  m*/
            Option.builder().longOpt(REPORT_OPTION).desc("The file where the documentation report be created.")
                    .type(File.class).required(false).hasArg(true).argName("FILE").build());
    options.addOption(Option.builder().longOpt(RESOURCES_OPTION)
            .desc("The directory where the resources files will be created.").type(File.class).required(false)
            .hasArg(true).argName("DIRECTORY").build());

    // Parse the command line:
    CommandLineParser parser = new DefaultParser();
    CommandLine line = null;
    try {
        line = parser.parse(options, args);
    } catch (ParseException exception) {
        System.err.println(exception.getMessage());
        HelpFormatter formatter = new HelpFormatter();
        formatter.setSyntaxPrefix("Usage: ");
        formatter.printHelp("metamodel-tool [OPTIONS]", options);
        System.exit(1);
    }

    // Extract the locations of files and directories from the command line:
    File modelFile = (File) line.getParsedOptionValue(MODEL_OPTION);
    File xmlFile = (File) line.getParsedOptionValue(XML_DESCRIPTION_OPTION);
    File jsonFile = (File) line.getParsedOptionValue(JSON_DESCRIPTION_OPTION);
    File inSchemaFile = (File) line.getParsedOptionValue(IN_SCHEMA_OPTION);
    File outSchemaFile = (File) line.getParsedOptionValue(OUT_SCHEMA_OPTION);
    File jaxrsDir = (File) line.getParsedOptionValue(JAXRS_OPTION);
    File javaDir = (File) line.getParsedOptionValue(JAVA_OPTION);
    File docsDir = (File) line.getParsedOptionValue(DOCS_OPTION);
    File reportFile = (File) line.getParsedOptionValue(REPORT_OPTION);
    File resourcesDir = (File) line.getParsedOptionValue(RESOURCES_OPTION);

    // Analyze the model files:
    Model model = new Model();
    ModelAnalyzer modelAnalyzer = new ModelAnalyzer();
    modelAnalyzer.setModel(model);
    modelAnalyzer.analyzeSource(modelFile);

    // Add the built-in types to the model:
    builtinTypes.addBuiltinTypes(model);

    // Extract the version prefix from the command line and copy it to the object that manages names:
    String versionPrefix = line.getOptionValue(VERSION_PREFIX_OPTION);
    if (versionPrefix != null) {
        versionedJavaNames.setVersionPrefix(versionPrefix);
    }

    // Extract the names of the Java packages from the command line and copy them to the object that manages them:
    String[] jaxrsPackages = line.getOptionValues(JAXRS_PACKAGE_OPTION);
    if (jaxrsPackages != null) {
        for (String jaxrsPackage : jaxrsPackages) {
            javaPackages.addJaxrsRule(jaxrsPackage);
        }
    }
    String xjcPackage = line.getOptionValue(XJC_PACKAGE_OPTION);
    if (xjcPackage != null) {
        javaPackages.setXjcPackageName(xjcPackage);
    }
    String typesPackage = line.getOptionValue(TYPES_PACKAGE_OPTION);
    if (typesPackage != null) {
        javaPackages.setTypesPackageName(typesPackage);
    }
    String containersPackage = line.getOptionValue(CONTAINERS_PACKAGE_OPTION);
    if (containersPackage != null) {
        javaPackages.setContainersPackageName(containersPackage);
    }
    String buildersPackage = line.getOptionValue(BUILDERS_PACKAGE_OPTION);
    if (buildersPackage != null) {
        javaPackages.setBuildersPackageName(buildersPackage);
    }
    String jsonPackage = line.getOptionValue(JSON_PACKAGE_OPTION);
    if (jsonPackage != null) {
        javaPackages.setJsonPackageName(jsonPackage);
    }
    String xmlPackage = line.getOptionValue(XML_PACKAGE_OPTION);
    if (xmlPackage != null) {
        javaPackages.setXmlPackageName(xmlPackage);
    }

    // Extract the documentation attributes:
    String[] adocAttributeArgs = line.getOptionValues(ADOC_ATTRIBUTE_OPTION);
    if (adocAttributeArgs != null) {
        for (String adocAttributeArg : adocAttributeArgs) {
            Matcher adocAttributeMatch = ADOC_ATTRIBUTE_RE.matcher(adocAttributeArg);
            if (!adocAttributeMatch.matches()) {
                throw new IllegalArgumentException("The AsciiDoc attribute \"" + adocAttributeArg
                        + "\" doesn't match regular " + "expression \"" + ADOC_ATTRIBUTE_RE.pattern() + "\".");
            }
            String adocAttributeName = adocAttributeMatch.group("name");
            String adocAttributeValue = adocAttributeMatch.group("value");
            adocConfiguration.setAttribute(adocAttributeName, adocAttributeValue);
        }
    }

    // Get the AsciiDoc section id separator:
    String adocSeparator = line.getOptionValue(ADOC_SEPARATOR_OPTION);
    if (adocSeparator != null) {
        adocConfiguration.setSeparator(adocSeparator);
    }

    // Generate the XML representation of the model:
    if (xmlFile != null) {
        File xmlDir = xmlFile.getParentFile();
        FileUtils.forceMkdir(xmlDir);
        xmlDescriptionGenerator.generate(model, xmlFile);
    }

    // Generate the JSON representation of the model:
    if (jsonFile != null) {
        File jsonDir = jsonFile.getParentFile();
        FileUtils.forceMkdir(jsonDir);
        jsonDescriptionGenerator.generate(model, jsonFile);
    }

    // Generate the XML schema:
    if (inSchemaFile != null && outSchemaFile != null) {
        schemaGenerator.setInFile(inSchemaFile);
        schemaGenerator.setOutFile(outSchemaFile);
        schemaGenerator.generate(model);
    }

    // Generate the JAX-RS source:
    if (jaxrsDir != null) {
        FileUtils.forceMkdir(jaxrsDir);
        jaxrsGenerator.setOutDir(jaxrsDir);
        jaxrsGenerator.generate(model);
        // Generate the JAX-RS helper classes):
        jaxrsHelperGenerator.setOutDir(jaxrsDir);
        jaxrsHelperGenerator.generate(model);
    }

    // Generate the Java source:
    if (javaDir != null) {
        typesGenerator.setOutDir(javaDir);
        typesGenerator.generate(model);

        // Generate JSON support classes:
        jsonSupportGenerator.setOutDir(javaDir);
        jsonSupportGenerator.generate(model);

        // Generate XML support classes:
        xmlSupportGenerator.setOutDir(javaDir);
        xmlSupportGenerator.setResourcesDir(resourcesDir);
        xmlSupportGenerator.generate(model);
    }

    // Generate the documentation:
    if (docsDir != null) {
        docGenerator.setOutDir(docsDir);
        docGenerator.generate(model);
    }
    if (reportFile != null) {
        reportGenerator.setOutFile(reportFile);
        reportGenerator.generate(model);
    }
}

From source file:org.ovirt.engine.api.rsdl.RsdlIOManager.java

public static void main(String[] args) throws IOException {
    // Create the command line options:
    Options options = new Options();

    // Option for the API version:
    options.addOption(Option.builder().longOpt(API_VERSION_OPTION)
            .desc("The version number of the API, the default is version 3.").required(false).hasArg(true)
            .argName("VERSION").build());

    // Parse the command line:
    CommandLineParser parser = new DefaultParser();
    CommandLine line = null;/*from w w  w  . j  a v a  2 s  .c o m*/
    try {
        line = parser.parse(options, args);
    } catch (ParseException exception) {
        System.err.println(exception.getMessage());
        HelpFormatter formatter = new HelpFormatter();
        formatter.setSyntaxPrefix("Usage: ");
        formatter.printHelp("rsdl-io-manager [OPTIONS] DIRECTORY", options);
        System.exit(1);
    }

    // Extract the API version:
    String apiVersion = line.getOptionValue(API_VERSION_OPTION);
    if (apiVersion == null || apiVersion.isEmpty()) {
        apiVersion = API_VERSION_DEFAULT;
    }

    // Check the arguments:
    args = line.getArgs();
    if (args.length != 1) {
        System.err.println("Exactly one argument containing the output directory is required.");
        System.exit(1);
    }

    // Make sure that the output directory exists:
    File outputDirectory = new File(args[0]);
    FileUtils.forceMkdir(outputDirectory);

    // Copy the resources to the output directory:
    for (String resourceName : RESOURCE_NAMES) {
        exportResource(apiVersion, resourceName, outputDirectory);
    }
}

From source file:org.ovirt.sdk.go.Tool.java

public void run(String[] args) throws Exception {
    // Create the command line options:
    Options options = new Options();

    // Options for the locations of files and directories:
    options.addOption(Option.builder().longOpt(MODEL_OPTION)
            .desc("The directory or .jar file containing the source model files.").type(File.class)
            .required(true).hasArg(true).argName("DIRECTORY|JAR").build());

    // Options for the location of the generated Go sources:
    options.addOption(Option.builder().longOpt(OUT_OPTION)
            .desc("The directory where the generated Go source will be created.").type(File.class)
            .required(false).hasArg(true).argName("DIRECTORY").build());

    // Parse the command line:
    CommandLineParser parser = new DefaultParser();
    CommandLine line = null;//from ww  w . j av  a 2 s.c o  m
    try {
        line = parser.parse(options, args);
    } catch (ParseException exception) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.setSyntaxPrefix("Usage: ");
        formatter.printHelp("go-tool [OPTIONS]", options);
        System.exit(1);
    }

    // Extract the locations of files and directories from the command line:
    File modelFile = (File) line.getParsedOptionValue(MODEL_OPTION);
    File outDir = (File) line.getParsedOptionValue(OUT_OPTION);

    // Extract the version of the:
    String version = line.getOptionValue(VERSION_OPTION);

    // Analyze the model files:
    Model model = new Model();
    ModelAnalyzer modelAnalyzer = new ModelAnalyzer();
    modelAnalyzer.setModel(model);
    modelAnalyzer.analyzeSource(modelFile);

    // Add the built-in types:
    builtinTypes.addBuiltinTypes(model);

    // Run the generators:
    if (outDir != null) {
        FileUtils.forceMkdir(outDir);
        for (GoGenerator generator : generators) {
            generator.setOut(outDir);
            generator.generate(model);
        }
    }
}

From source file:org.ovirt.sdk.java.Tool.java

public void run(String[] args) throws Exception {
    // Create the command line options:
    Options options = new Options();

    // Options for the locations of files and directories:
    options.addOption(Option.builder().longOpt(MODEL_OPTION)
            .desc("The directory or .jar file containing the source model files.").type(File.class)
            .required(true).hasArg(true).argName("DIRECTORY|JAR").build());

    // Options for the location of the generated sources:
    options.addOption(Option.builder().longOpt(OUT_OPTION)
            .desc("The directory where the generated source will be created.").type(File.class).required(false)
            .hasArg(true).argName("DIRECTORY").build());

    // Options for the location of the generated sources:
    options.addOption(Option.builder().longOpt(RESOURCES_OPTION)
            .desc("The directory where the resources files will be created.").type(File.class).required(false)
            .hasArg(true).argName("DIRECTORY").build());

    // Parse the command line:
    CommandLineParser parser = new DefaultParser();
    CommandLine line = null;//from  w w w.ja  v a 2 s  .com
    try {
        line = parser.parse(options, args);
    } catch (ParseException exception) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.setSyntaxPrefix("Usage: ");
        formatter.printHelp("sdk-tool [OPTIONS]", options);
        System.exit(1);
    }

    // Extract the locations of files and directories from the command line:
    File modelFile = (File) line.getParsedOptionValue(MODEL_OPTION);
    File outDir = (File) line.getParsedOptionValue(OUT_OPTION);
    File resourcesDir = (File) line.getParsedOptionValue(RESOURCES_OPTION);

    // Analyze the model files:
    Model model = new Model();
    ModelAnalyzer modelAnalyzer = new ModelAnalyzer();
    modelAnalyzer.setModel(model);
    modelAnalyzer.analyzeSource(modelFile);

    // Generate href attribute to Identified type:
    addHrefAttributeToIdentifiedType(model);

    // Add the built-in types:
    builtinTypes.addBuiltinTypes(model);

    // Set the names of the packages:
    javaPackages.setTypesPackageName(BASE_PACKAGE + ".types");
    javaPackages.setContainersPackageName(BASE_PACKAGE + ".internal.containers");
    javaPackages.setBuildersPackageName(BASE_PACKAGE + ".builders");
    javaPackages.setXmlPackageName(BASE_PACKAGE + ".internal.xml");

    // Run the generators:
    if (outDir != null) {
        List<JavaGenerator> generators = new ArrayList<>();
        generators.add(structsGenerator);
        generators.add(xmlSupportGenerator);
        generators.add(enumGenerator);
        generators.add(servicesGenerator);
        generators.add(servicesImplGenerator);
        FileUtils.forceMkdir(outDir);
        for (JavaGenerator generator : generators) {
            generator.setOutDir(outDir);
            generator.setResourcesDir(resourcesDir);
            generator.generate(model);
        }
    }
}