Java源码示例:net.sourceforge.argparse4j.inf.ArgumentGroup

示例1
@Override
public void configure(Subparser subparser) {
    super.configure(subparser);

    subparser.addArgument("id")
            .required(true)
            .help("IDs for the report (IDs can be reused to continue a partially completed report)");

    subparser.addArgument("--placements")
            .dest("placements")
            .metavar("PLACEMENT")
            .nargs("+")
            .help("Limit report to the provided placements (by default all placements are included)");

    ArgumentGroup continuation = subparser.addArgumentGroup("continue")
            .description("Continue report from a specific shard and table");

    continuation.addArgument("--shard")
            .dest("shard")
            .type(Integer.class)
            .help("The shard ID to continue from (by default the report starts at the first shard)");

    continuation.addArgument("--table")
            .dest("table")
            .help("The UUID of the table to continue from (by default the report starts at the " +
                    "first table in the initial shard");

    subparser.addArgument("--readOnly")
            .action(new StoreTrueArgumentAction())
            .dest("readOnly")
            .help("Do not modify any data, such as fixing invalid compaction records");
}
 
示例2
@Override
protected void addArguments(ArgumentParser parser) {
    ArgumentGroup schemaGroup = parser.addArgumentGroup("schemas");
    schemaGroup.description("Schemas generated by this script");

    schemaGroup.addArgument("--emoSchema")
            .dest("emoSchema")
            .metavar("NAME")
            .nargs("?")
            .help("Name of the schema where \"emodb\" located tables are generated");

    schemaGroup.addArgument("--stashSchema")
            .dest("stashSchema")
            .metavar("NAME")
            .nargs("?")
            .help("Name of the schema where \"emostash\" located tables are generated");

    parser.addArgument("--location")
            .dest("location")
            .metavar("EMOURL")
            .nargs("?")
            .required(true)
            .help("URI location of the EmoDB server, such as \"emodb://ci.us\"");

    parser.addArgument("--apiKey")
            .dest("apiKey")
            .metavar("KEY")
            .nargs("?")
            .required(true)
            .help("API key for connecting to EmoDB");

    parser.addArgument("--compatibility")
            .dest("compatibility")
            .nargs("?")
            .choices("hive", "general")
            .setDefault("hive")
            .help("hive = Use custom SerDe and InputFormat to provide efficiency and rich column names (default).  " +
                    "general = No custom SerDe or InputFormat so is more compatible with Hive alternatives like " +
                    "Presto and Impala but is slightly less efficient and only provides a single JSON column.");

    parser.addArgument("--disableIfNotExists")
            .dest("disableIfNotExists")
            .action(storeTrue())
            .setDefault(false)
            .help("Disables \"IF NOT EXISTS\" from being included in each \"CREATE TABLE\" command");

    parser.addArgument("--recreateTables")
            .dest("recreateTables")
            .action(storeTrue())
            .setDefault(false)
            .help("Drops each table if it exists prior to the \"CREATE TABLE\" command");
}