Example usage for org.apache.commons.cli Option setArgName

List of usage examples for org.apache.commons.cli Option setArgName

Introduction

In this page you can find the example usage for org.apache.commons.cli Option setArgName.

Prototype

public void setArgName(String argName) 

Source Link

Document

Sets the display name for the argument value.

Usage

From source file:org.deegree.tools.coverage.TransformRaster.java

/**
 * @param args/*from ww w  .j  a  v a 2 s.c o  m*/
 */
public static void main(String[] args) {
    CommandLineParser parser = new PosixParser();

    Options options = new Options();

    Option t_srs = new Option("t_srs", "the srs of the target raster");
    t_srs.setRequired(true);
    t_srs.setArgs(1);
    t_srs.setArgName("epsg code");
    options.addOption(t_srs);

    Option s_srs = new Option("s_srs", "the srs of the source raster");
    s_srs.setRequired(true);
    s_srs.setArgs(1);
    s_srs.setArgName("epsg code");
    options.addOption(s_srs);

    Option interpolation = new Option("interpolation",
            "the raster interpolation (nn: nearest neighbour, bl: bilinear");
    interpolation.setArgs(1);
    interpolation.setArgName("nn|bl");
    options.addOption(interpolation);

    Option originLocation = new Option("origin", "originlocation", true,
            "the location of the origin on the upper left pixel (default = center)");
    interpolation.setArgs(1);
    interpolation.setArgName("center|outer");
    options.addOption(originLocation);

    CommandUtils.addDefaultOptions(options);

    // for the moment, using the CLI API there is no way to respond to a help argument; see
    // https://issues.apache.org/jira/browse/CLI-179
    if (args.length == 0 || (args.length > 0 && (args[0].contains("help") || args[0].contains("?")))) {
        printHelp(options);
    }

    try {
        CommandLine line = parser.parse(options, args);

        InterpolationType interpolationType = getInterpolationType(line.getOptionValue(interpolation.getOpt()));
        OriginLocation location = getLocation(line.getOptionValue(originLocation.getOpt()));

        transformRaster(line.getArgs(), line.getOptionValue("s_srs"), line.getOptionValue("t_srs"),
                interpolationType, location);

    } catch (ParseException exp) {
        System.out.println("ERROR: Invalid command line:" + exp.getMessage());
    }
    System.exit(0);
}

From source file:org.deegree.tools.rendering.manager.DataManager.java

private static Options initOptions() {
    Options options = new Options();

    Option option = new Option(OPT_FILE.substring(0, 1), OPT_FILE, true, "the file containing data to import");
    option.setArgs(1);//from  w w w  .j a  va 2  s  .  c  o m
    option.setArgName("relative/absolut file location");
    options.addOption(option);

    option = new Option("ql", QL, true, "defines the quality level of the data the action should operate on");
    option.setArgs(1);
    option.setArgName("[1-5] if " + TYPE + "=prototype, '1' is expected");
    options.addOption(option);

    option = new Option("cll", OPT_CREATE_LOWEST_LEVELS, false,
            "A flag defining if the lowest levels (convexhull, protoype box ref) should be created for the buildings.");
    options.addOption(option);

    option = new Option("td", OPT_TEXTURE_DIR, true, "Directory where texture can be found.");
    option.setArgs(1);
    option.setArgName("path to the directory");
    options.addOption(option);

    option = new Option("id", OPT_UUID, true,
            "ID of the building to delete or of a vrml file, if not provided the file name will be used.");
    option.setArgs(1);
    option.setArgName("The id of the building.");
    options.addOption(option);

    option = new Option("tt", OPT_WPVS_TRANSLATION_TO, true,
            "A comma separated vector, translation vector to the nullpoint of the WPVS (see the WPVS-Config for more information).");
    option.setArgs(1);
    option.setArgName("e.g. -tt \"-2568000,-5606000\"  .");
    options.addOption(option);

    option = new Option("sw", OPT_DELETE_SQL, true,
            "SQL where statement which defines a where cause on the db.");
    option.setArgs(1);
    option.setArgName("a delete sql where statement, e.g. \"WHERE id='building_id'");
    options.addOption(option);

    addActionParameters(options);
    addTypeParameters(options);
    addDatabaseParameters(options);
    addVRMLParameters(options);
    addCityGMLParameters(options);

    CommandUtils.addDefaultOptions(options);

    return options;

}

From source file:org.deegree.tools.rendering.manager.DataManager.java

/**
 * @param options//from   ww  w .j ava2 s .  c  o m
 */
private static void addActionParameters(Options options) {
    Option option = new Option(ACTION.substring(0, 1), ACTION, true,
            "defines the action the manager should perform");
    option.setArgs(1);
    StringBuilder argNames = new StringBuilder();
    Action[] allActions = Action.values();
    for (int i = 0; i < allActions.length; ++i) {
        Action a = allActions[i];
        argNames.append(a);
        if ((i + 1) < allActions.length) {
            argNames.append("|");
        }
    }
    option.setArgName(argNames.toString());
    option.setRequired(true);
    options.addOption(option);
}

From source file:org.deegree.tools.rendering.manager.DataManager.java

/**
 * @param options/*w  w  w  .  ja v  a 2s  .  c o  m*/
 */
private static void addTypeParameters(Options options) {
    Option option = new Option(TYPE.substring(0, 1), TYPE, true,
            "defines the type of data the manager expects");
    option.setArgs(1);
    StringBuilder argNames = new StringBuilder();
    Type[] allTypes = Type.values();
    for (int i = 0; i < allTypes.length; ++i) {
        Type a = allTypes[i];
        argNames.append(a);
        if ((i + 1) < allTypes.length) {
            argNames.append("|");
        }
    }
    option.setArgName(argNames.toString());
    option.setRequired(true);
    options.addOption(option);
}

From source file:org.deegree.tools.rendering.manager.DataManager.java

/**
 * Database parameters/*w ww  . ja  v a 2 s  .c  o m*/
 * 
 * @param options
 *            to add the database option to.
 */
private static void addDatabaseParameters(Options options) {

    Option option = new Option("host", DB_HOST, true, "url to the database, with or without port");
    option.setArgs(1);
    option.setArgName("for example jdbc:postgresql://dbhost:5432/db_name");
    option.setRequired(true);
    options.addOption(option);

    option = new Option("fbd", OPT_FILE_BACKEND_DIR, true, "directory to be used for the file databackend");
    option.setArgs(1);
    option.setArgName("for example /home/file_backend");
    options.addOption(option);

    option = new Option(OPT_DB_USER.substring(0, 1), OPT_DB_USER, true,
            "username of the database, default will be ${user.name}");
    option.setArgs(1);
    option.setArgName("for example postgres");
    options.addOption(option);

    option = new Option(OPT_DB_PASS.substring(0, 1), OPT_DB_PASS, true,
            "password of the database, default will be empty");
    option.setArgs(1);
    option.setArgName("for example my_secret_password");
    options.addOption(option);

}

From source file:org.deegree.tools.rendering.manager.DataManager.java

/**
 * VRML file reading parameters/* www . j  a va  2  s .c om*/
 * 
 * @param options
 *            to add the vrml options to.
 */
private static void addVRMLParameters(Options options) {

    Option option = new Option("tx", OPT_VRML_TRANSLATION_X, true,
            "Translation of the x values of the vrml file.");
    option.setArgs(1);
    option.setArgName("Easting translation.");
    options.addOption(option);

    option = new Option("ty", OPT_VRML_TRANSLATION_Y, true, "Translation of the y values of the vrml file.");
    option.setArgs(1);
    option.setArgName("Northing translation.");
    options.addOption(option);

    option = new Option("tz", OPT_VRML_TRANSLATION_Z, true, "Translation of the z values of the vrml file.");
    option.setArgs(1);
    option.setArgName("Up translation.");
    options.addOption(option);

    option = new Option("ra", OPT_VRML_ROTATION_AXIS, true,
            "Rotation axis, comma separated values: x,y,z,angle.");
    option.setArgs(1);
    option.setArgName("Rotation axis.");
    options.addOption(option);

    option = new Option("yz", OPT_VRML_FLIP_Y_Z, false, "Flip the y and z coordinates of the vrml file.");
    options.addOption(option);

    option = new Option("mtd", OPT_VRML_MAX_TEX_DIM, true,
            "The maximum dimension of the textures of the given vrml file, will be 'upped' to the power of two.");
    option.setArgs(1);
    option.setArgName("The maximum dimension of a texture.");
    options.addOption(option);

}

From source file:org.deegree.tools.rendering.manager.DataManager.java

/**
 * CityGML file reading parameters//from  ww  w  . ja  va  2s . c om
 * 
 * @param options
 *            to add the vrml options to.
 */
private static void addCityGMLParameters(Options options) {

    Option option = new Option("cgsl", OPT_CITY_GML_SCHEMA, true,
            "Local location of the citygml schema files.");
    option.setArgs(1);
    option.setArgName("File location.");
    options.addOption(option);

    option = new Option("bc", OPT_CITY_GML_COLOR, true,
            "Default color of the citygml buildings in #FFUUFF format.");
    option.setArgs(1);
    option.setArgName("Default color.");
    options.addOption(option);

    option = new Option("ogcns", OPT_USE_OPENGIS, false,
            "Optional flag for using the opengis namespace for citygml buildings.");
    options.addOption(option);

}

From source file:org.deegree.tools.rendering.manager.ModelGeneralizor.java

private static Options initOptions() {
    Options options = new Options();

    Option option = new Option("type", TYPE, true, "the type of object to assign a prototype to (building)");
    option.setArgs(1);//  w w  w  .  j  ava  2 s  .c o  m
    option.setArgName("building");
    option.setRequired(true);
    options.addOption(option);

    option = new Option("ql", TARGET_QL, true,
            "defines the quality level of the data the generalistation should be assigned to");
    option.setArgs(1);
    option.setArgName("[0,1]");
    option.setRequired(true);
    options.addOption(option);

    option = new Option("source", SOURCE_QL, true,
            "defines the quality level of the data from which the generalistation should be constructed from");
    option.setArgs(1);
    option.setArgName("[2,5]");
    option.setRequired(true);
    options.addOption(option);

    option = new Option("tt", WPVS_TRANSLATION_TO, true,
            "A comma seperated translation vector to the nullpoint of the WPVS (see the WPVS-Config for more information).");
    option.setArgs(1);
    option.setRequired(true);
    option.setArgName("e.g. \"-2568000,-5606000\"  .");
    options.addOption(option);

    option = new Option("sw", SQL_WHERE, true, "SQL where statement which defines a where cause on the db.");
    option.setArgs(1);
    option.setArgName("\"WHERE id='building_id'\"");
    options.addOption(option);

    addDatabaseParameters(options);

    CommandUtils.addDefaultOptions(options);
    return options;

}

From source file:org.deegree.tools.rendering.manager.ModelGeneralizor.java

/**
 * Database parameters/* ww  w .  j a v  a2 s.co m*/
 * 
 * @param options
 *            to add the database option to.
 */
private static void addDatabaseParameters(Options options) {

    Option option = new Option("host", DB_HOST, true, "url to the database, with or without port");
    option.setArgs(1);
    option.setArgName("for example jdbc:postgresql://dbhost:5432/db_name");
    option.setRequired(true);
    options.addOption(option);

    option = new Option(OPT_DB_USER.substring(0, 1), OPT_DB_USER, true,
            "username of the database, default will be ${user.name}");
    option.setArgs(1);
    option.setArgName("for example postgres");
    options.addOption(option);

    option = new Option(OPT_DB_PASS.substring(0, 1), OPT_DB_PASS, true,
            "password of the database, default will be empty");
    option.setArgs(1);
    option.setArgName("for example my_secret_password");
    options.addOption(option);

}

From source file:org.deegree.tools.rendering.manager.PrototypeAssigner.java

private static Options initOptions() {
    Options options = new Options();

    Option option = new Option("type", TYPE, true, "the type of object to assign a prototype to (building)");
    option.setArgs(1);/*from  w  w w  .ja  v  a2 s .c o  m*/
    option.setArgName("building");
    option.setRequired(true);
    options.addOption(option);

    option = new Option("ql", QL, true,
            "defines the quality level of the data the prototype should be assigned to");
    option.setArgs(1);
    option.setArgName("[0-5]");
    option.setRequired(true);
    options.addOption(option);

    option = new Option("id", BUILDING_ID, true, "UUID of the building to assign the prototype to.");
    option.setArgs(1);
    option.setArgName("The uuid of the building.");
    option.setRequired(true);
    options.addOption(option);

    option = new Option("pid", PROTOTYPE_ID, true, "UUID of the prototype to assign to the building.");
    option.setArgs(1);
    option.setArgName("The uuid of the prototype.");
    option.setRequired(true);
    options.addOption(option);

    option = new Option("tt", WPVS_TRANSLATION_TO, true,
            "A comma seperated translation vector to the nullpoint of the WPVS (see the WPVS-Config for more information).");
    option.setArgs(1);
    option.setRequired(true);
    option.setArgName("e.g. \"-2568000,-5606000\"  .");
    options.addOption(option);

    option = new Option("t", TRANSLATION, true,
            "A comma seperated 3D translation vector to the middle point of the bbox of this building.");
    option.setArgs(1);
    option.setArgName("Building origin e.g. \"2568000,5606000,18\"  .");
    option.setRequired(true);
    options.addOption(option);

    option = new Option("r", ROTATION, true, "Z-Axis rotation in degrees.");
    option.setArgs(1);
    option.setArgName("A rotation in degrees.");
    option.setRequired(true);
    options.addOption(option);

    option = new Option("w", WIDTH, true, "Width of the prototype (x-axis).");
    option.setArgs(1);
    option.setArgName("The width of the building.");
    option.setRequired(true);
    options.addOption(option);

    option = new Option("h", HEIGHT, true, "Height of the prototype (z-axis).");
    option.setArgs(1);
    option.setArgName("The height of the building.");
    option.setRequired(true);
    options.addOption(option);

    option = new Option("d", DEPTH, true, "Depth of the prototype (y-axis).");
    option.setArgs(1);
    option.setArgName("The depth of the building.");
    option.setRequired(true);
    options.addOption(option);

    addDatabaseParameters(options);

    CommandUtils.addDefaultOptions(options);

    return options;

}