use of org.apache.commons.cli.HelpFormatter in project alluxio by Alluxio.
the class AlluxioFuse method parseOptions.
/**
* Parses CLI options.
*
* @param args CLI args
* @return Alluxio-FUSE configuration options
*/
private static AlluxioFuseOptions parseOptions(String[] args) {
final Options opts = new Options();
final Option mntPoint = Option.builder("m").hasArg().required(false).longOpt("mount-point").desc("Desired local mount point for alluxio-fuse.").build();
final Option alluxioRoot = Option.builder("r").hasArg().required(false).longOpt("alluxio-root").desc("Path within alluxio that will be used as the root of the FUSE mount " + "(e.g., /users/foo; defaults to /)").build();
final Option help = Option.builder("h").required(false).desc("Print this help").build();
final Option fuseOption = Option.builder("o").valueSeparator(',').required(false).hasArgs().desc("FUSE mount options").build();
opts.addOption(mntPoint);
opts.addOption(alluxioRoot);
opts.addOption(help);
opts.addOption(fuseOption);
final CommandLineParser parser = new DefaultParser();
try {
CommandLine cli = parser.parse(opts, args);
if (cli.hasOption("h")) {
final HelpFormatter fmt = new HelpFormatter();
fmt.printHelp(AlluxioFuse.class.getName(), opts);
return null;
}
String mntPointValue = cli.getOptionValue("m");
String alluxioRootValue = cli.getOptionValue("r");
List<String> fuseOpts = new ArrayList<>();
boolean noUserMaxWrite = true;
if (cli.hasOption("o")) {
String[] fopts = cli.getOptionValues("o");
// keep the -o
for (final String fopt : fopts) {
fuseOpts.add("-o" + fopt);
if (noUserMaxWrite && fopt.startsWith("max_write")) {
noUserMaxWrite = false;
}
}
}
// from conf
if (noUserMaxWrite) {
final long maxWrite = Configuration.getLong(PropertyKey.FUSE_MAXWRITE_BYTES);
fuseOpts.add(String.format("-omax_write=%d", maxWrite));
}
if (mntPointValue == null) {
mntPointValue = Configuration.get(PropertyKey.FUSE_MOUNT_DEFAULT);
LOG.info("Mounting on default {}", mntPointValue);
}
if (alluxioRootValue == null) {
alluxioRootValue = Configuration.get(PropertyKey.FUSE_FS_ROOT);
LOG.info("Using default alluxio root {}", alluxioRootValue);
}
final boolean fuseDebug = Configuration.getBoolean(PropertyKey.FUSE_DEBUG_ENABLED);
return new AlluxioFuseOptions(mntPointValue, alluxioRootValue, fuseDebug, fuseOpts);
} catch (ParseException e) {
System.err.println("Error while parsing CLI: " + e.getMessage());
final HelpFormatter fmt = new HelpFormatter();
fmt.printHelp(AlluxioFuse.class.getName(), opts);
return null;
}
}
use of org.apache.commons.cli.HelpFormatter in project alluxio by Alluxio.
the class GetConf method printHelp.
/**
* Prints the help message.
*
* @param message message before standard usage information
*/
public static void printHelp(String message) {
System.err.println(message);
HelpFormatter help = new HelpFormatter();
help.printHelp(USAGE, OPTIONS);
}
use of org.apache.commons.cli.HelpFormatter in project zm-mailbox by Zimbra.
the class LocalConfigCLI method usage.
/**
* Prints supported usage to stdout. Removes hidden options from the list to be printed
*
*/
private void usage() {
Collection<Object> options = mOptions.getOptions();
Options displayOptions = new Options();
for (Object obj : options) {
// copy over the supported options
// should be a safe cast, this api REALLY needs generics
Option opt = (Option) obj;
if (!"all".equals(opt.getLongOpt())) {
displayOptions.addOption(opt);
}
}
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("zmlocalconfig [options] [args]", "where [options] are:", displayOptions, "");
System.exit(0);
}
use of org.apache.commons.cli.HelpFormatter in project zm-mailbox by Zimbra.
the class SmtpClient method usage.
private void usage() {
HelpFormatter help = new HelpFormatter();
help.setWidth(100);
help.printHelp("zmjava " + getClass().getName() + " [OPTIONS] [HOSTNAME]", options);
}
use of org.apache.commons.cli.HelpFormatter in project zm-mailbox by Zimbra.
the class ProxyConfUtil method usage.
private static void usage(String errmsg) {
if (errmsg != null) {
System.out.println(errmsg);
}
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("ProxyConfGen [options] ", "where [options] are one of:", mOptions, "ProxyConfGen generates the NGINX Proxy configuration files");
}
Aggregations