Java Code Examples for org.apache.commons.cli.Option#builder()

The following examples show how to use org.apache.commons.cli.Option#builder() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IsTargetOption.java    From svg2vector with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the new option as not required and without a short option.
 * @param target the target to which this option applies, must not be null
 * @param isCli the Inkscape command line option to be used including any leading dashs, must not be blank
 * @param longOption the long option, must not be blank
 * @param argument the argument, no argument added if blank
 * @param description the short description, must not be blank
 * @param longDescription the long description, must not be blank
 * @throws NullPointerException - if any required parameter is null
 * @throws IllegalArgumentException - if any required parameter is null
 */
public IsTargetOption(SvgTargets target, String isCli, String longOption, String argument, String description, String longDescription){
	super(description, longDescription);
	Validate.notNull(target);
	Validate.notBlank(isCli);
	Validate.notBlank(longOption);

	Option.Builder builder = Option.builder();
	builder.longOpt(longOption);
	if(!StringUtils.isBlank(argument)){
		builder.hasArg().argName(argument);
	}
	builder.required(false);
	this.setCliOption(builder.build());

	this.target = target;
	this.isCli = isCli;
}
 
Example 2
Source File: AO_UseBaseName.java    From svg2vector with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the new option.
 */
public AO_UseBaseName(){
	super("use specified base name for output", "When processing layers, use the given base name for created output files.");

	Option.Builder builder = Option.builder();
	builder.longOpt("use-basename");
	builder.hasArg().argName("BASENAME");
	builder.required(false);
	this.setCliOption(builder.build());
}
 
Example 3
Source File: AO_SvgFirst.java    From svg2vector with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the new option.
 * @param required true if option is required, false of it is optional
 * @param shortOption character for sort version of the option
 * @param longDescription option long description
 * @throws NullPointerException - if description parameter is null
 * @throws IllegalArgumentException - if description parameter is empty
 */
public AO_SvgFirst(boolean required, Character shortOption, String longDescription){
	super("convert to SVG first, then to actual target", longDescription);

	Option.Builder builder = (shortOption==null)?Option.builder():Option.builder(shortOption.toString());
	builder.longOpt("svg-first");
	builder.required(required);
	this.setCliOption(builder.build());
}
 
Example 4
Source File: AO_InkscapeExecutable.java    From svg2vector with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the new option.
 * @param shortOption character for sort version of the option
 * @throws NullPointerException - if description parameter is null
 * @throws IllegalArgumentException - if description parameter is empty
 */
public AO_InkscapeExecutable(Character shortOption){
	super("path to Inkscape executable",
			"This option, if used, needs to point to the Inkscape executable. " +
			"Some default values are set in the following way: " +
			"first, the environment variable <" + ENV_KEY + "> is tested. If it is not null, it's value is set as default for the option. " +
			"Next, if the underlying operating system is a Windows system (using Apache SystemUtils), the default value is set to <" + DEFAULT_WINDOWS + ">. " +
			"Next, if the underlying operating system is a UNIX system (using Apache SystemUtils), the default value is set to <" + DEFAULT_UNIX + ">. " +
			"In all other cases, no default value will be set." +
			"\n" +
			"Using the option in the command line will use the given executable and ignore any default settings."
	);

	Option.Builder builder = (shortOption==null)?Option.builder():Option.builder(shortOption.toString());
	builder.longOpt("is-exec");
	builder.hasArg().argName("PATH");
	builder.required(false);
	this.setCliOption(builder.build());

	String env = System.getenv(ENV_KEY);
	if(env!=null){
		this.setDefaultValue(env);
	}
	else if(SystemUtils.IS_OS_WINDOWS){
		this.setDefaultValue("C:/Program Files/Inkscape/inkscape.exe");
	}
	else if(SystemUtils.IS_OS_UNIX){
		this.setDefaultValue("/usr/bin/inkscape");
	}
}
 
Example 5
Source File: AO_ManualLayers.java    From svg2vector with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the new option.
 * @param required true if option is required, false of it is optional
 * @param shortOption character for sort version of the option
 * @param longDescription option long description
 * @throws NullPointerException - if description parameter is null
 * @throws IllegalArgumentException - if description parameter is empty
 */
public AO_ManualLayers(boolean required, Character shortOption, String longDescription){
	super("manage layers manually when creating tmp directory", longDescription);

	Option.Builder builder = (shortOption==null)?Option.builder():Option.builder(shortOption.toString());
	builder.longOpt("manual-layers");
	builder.required(required);
	this.setCliOption(builder.build());
}
 
Example 6
Source File: AO_NotTransparent.java    From svg2vector with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the new option.
 * @param required true if option is required, false of it is optional
 * @param shortOption character for sort version of the option
 * @param longDescription option long description
 * @throws NullPointerException - if description parameter is null
 * @throws IllegalArgumentException - if description parameter is empty
 */
public AO_NotTransparent(boolean required, Character shortOption, String longDescription){
	super("not transparent", longDescription);

	Option.Builder builder = (shortOption==null)?Option.builder():Option.builder(shortOption.toString());
	builder.longOpt("not-transparent");
	builder.required(required);
	this.setCliOption(builder.build());
}
 
Example 7
Source File: AO_CreateDirectories.java    From svg2vector with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the new option.
 */
public AO_CreateDirectories(){
	super("automatically create directories for output", "With this option, any non-existent directory for output file(s) will automatically be created. Use with care!");

	Option.Builder builder = Option.builder();
	builder.longOpt("create-directories");
	builder.required(false);
	this.setCliOption(builder.build());
}
 
Example 8
Source File: AO_Simulate.java    From svg2vector with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the new option.
 */
public AO_Simulate(){
	super("simulate application, no file output", "This option puts the application into simulation mode. All actions will be done as normal, except no directories will be created and no file will be created or written. This includes temporary directories. Use this option with detailed messaging to see what would happen for a given application run.");

	Option.Builder builder = Option.builder("S");
	builder.longOpt("simulate");
	builder.required(false);
	this.setCliOption(builder.build());
}
 
Example 9
Source File: AO_MsgDetail.java    From svg2vector with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the new option.
 */
public AO_MsgDetail(){
	super("print detailed information to stdout", "print all detailed information to stdout");

	Option.Builder builder = Option.builder("e");
	builder.longOpt("print-details");
	builder.required(false);
	this.setCliOption(builder.build());
}
 
Example 10
Source File: AO_FoutNoBasename.java    From svg2vector with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the new option.
 */
public AO_FoutNoBasename(){
	super("when processing layers, do not use a basename for output files", "If layers are processed, no basename will be used for output files (requires layer index or layer identifier to be activated for valid file names");

	Option.Builder builder = Option.builder();
	builder.longOpt("fout-no-basename");
	builder.required(false);
	this.setCliOption(builder.build());
}
 
Example 11
Source File: AO_FoutLayerIndex.java    From svg2vector with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the new option.
 */
public AO_FoutLayerIndex(){
	super("use layer index in output file name", "If layers are processed, the output file name will use the layer index (after optional base name, before file extension or optional layer identifier)");

	Option.Builder builder = Option.builder("i");
	builder.longOpt("fout-layer-index");
	builder.required(false);
	this.setCliOption(builder.build());
}
 
Example 12
Source File: AO_KeepTmpArtifacts.java    From svg2vector with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the new option.
 */
public AO_KeepTmpArtifacts(){
	super("keep temporary created artifacts (files and directories)", "With this option, any temporary created artifact (files and directories) will not be removed.");

	Option.Builder builder = Option.builder();
	builder.longOpt("keep-tmp-artifacts");
	builder.required(false);
	this.setCliOption(builder.build());
}
 
Example 13
Source File: AO_NoBackground.java    From svg2vector with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the new option.
 * @param required true if option is required, false of it is optional
 * @param shortOption character for sort version of the option
 * @param longDescription option long description
 * @throws NullPointerException - if description parameter is null
 * @throws IllegalArgumentException - if description parameter is empty
 */
public AO_NoBackground(boolean required, Character shortOption, String longDescription){
	super("no background", longDescription);

	Option.Builder builder = (shortOption==null)?Option.builder():Option.builder(shortOption.toString());
	builder.longOpt("no-background");
	builder.required(required);
	this.setCliOption(builder.build());
}
 
Example 14
Source File: AO_OverwriteExisting.java    From svg2vector with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the new option.
 */
public AO_OverwriteExisting(){
	super("overwrite existing files on output", "With this option, existing files will be overwritten when generating output. Use with care!");

	Option.Builder builder = Option.builder();
	builder.longOpt("overwrite-existing");
	builder.required(false);
	this.setCliOption(builder.build());
}
 
Example 15
Source File: AO_Layers.java    From svg2vector with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the new option.
 */
public AO_Layers(){
	super("process layers, create one file per layer", "Create one output file (for given target) file per Inkscape layer. Input files without layers will not be processed with this option.");

	Option.Builder builder = Option.builder("l");
	builder.longOpt("layers");
	builder.required(false);
	this.setCliOption(builder.build());
}
 
Example 16
Source File: AO_MsgProgress.java    From svg2vector with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the new option.
 */
public AO_MsgProgress(){
	super("print progress information to stdout", "print all progress information but no extended details to stdout");

	Option.Builder builder = Option.builder("p");
	builder.longOpt("print-progress");
	builder.required(false);
	this.setCliOption(builder.build());
}
 
Example 17
Source File: AO_LayersIfExist.java    From svg2vector with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the new option.
 */
public AO_LayersIfExist(){
	super("process layers if if input file has layers, create one file per layer", "Create one output file (for given target) file per Inkscape layer. Input files without layers will be processed normally. This option might result in the input file being openend and read more than once.");

	Option.Builder builder = Option.builder("L");
	builder.longOpt("layers-if-exist");
	builder.required(false);
	this.setCliOption(builder.build());
}
 
Example 18
Source File: AO_Clip.java    From svg2vector with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the new option.
 * @param required true if option is required, false of it is optional
 * @param shortOption character for sort version of the option
 * @param longDescription option long description
 * @throws NullPointerException - if description parameter is null
 * @throws IllegalArgumentException - if description parameter is empty
 */
public AO_Clip(boolean required, Character shortOption, String longDescription){
	super("clip", longDescription);

	Option.Builder builder = (shortOption==null)?Option.builder():Option.builder(shortOption.toString());
	builder.longOpt("clip");
	builder.required(required);
	this.setCliOption(builder.build());
}
 
Example 19
Source File: AO_FoutLayerId.java    From svg2vector with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the new option.
 */
public AO_FoutLayerId(){
	super("use layer identifier (id) in output file name", "If layers are processed, the output file name will use the layer identifier (after optional index, before file extension)");

	Option.Builder builder = Option.builder("I");
	builder.longOpt("fout-layer-id");
	builder.required(false);
	this.setCliOption(builder.build());
}
 
Example 20
Source File: AO_BackgroundColor.java    From svg2vector with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the new option.
 * @param required true if option is required, false of it is optional
 * @param shortOption character for sort version of the option
 * @param longDescription option long description
 * @throws NullPointerException - if description parameter is null
 * @throws IllegalArgumentException - if description parameter is empty
 */
public AO_BackgroundColor(boolean required, Character shortOption, String longDescription){
	super("background color", longDescription);

	Option.Builder builder = (shortOption==null)?Option.builder():Option.builder(shortOption.toString());
	builder.longOpt("bgrnd-color");
	builder.hasArg().argName("COLOR");
	builder.required(required);
	this.setCliOption(builder.build());
}