static List<String> getStringList(CommandLine commandLine, Option option) { return commandLine.getValues(option); }
static String getString(CommandLine commandLine, Option option) { Object val = commandLine.getValue(option); if (val != null) { return val.toString(); } return null; }
/** * @param name The name of the option * @return the {@link org.apache.commons.cli2.Option} with the name, else null */ protected Option getCLIOption(String name) { for (Option option : options) { if (option.getPreferredName().equals(name)) { return option; } } return null; }
public Object getOptionValue(String optName) { if (cmdLine == null) throw new IllegalStateException(); return this.cmdLine.getValue(optName); }
protected int getFormatFlags(VaultFsConsoleExecutionContext ctx, CommandLine cl) { int fmtFlag = 0; fmtFlag |= cl.hasOption(optTime) ? F_FLAG_TIME : 0; fmtFlag |= cl.hasOption(optSize) ? F_FLAG_SIZE : 0; fmtFlag |= cl.hasOption(optMime) ? F_FLAG_MIME : 0; fmtFlag |= cl.hasOption(optLong) ? F_FLAG_LONG : 0; return fmtFlag; }
/** * @param name The name of the option * @return the {@link org.apache.commons.cli2.Option} with the name, else null */ protected Option getCLIOption(String name) { for (Option option : options) { if (option.getPreferredName().equals(name)) { return option; } } return null; }
public Object getOptionValue(Option opt) { if (cmdLine == null) throw new IllegalStateException(); return this.cmdLine.getValue(opt); }
protected int getFormatFlags(VaultFsConsoleExecutionContext ctx, CommandLine cl) { int fmtFlag = 0; fmtFlag |= cl.hasOption(optType) ? F_FLAG_TYPE : 0; return fmtFlag; }
/** * @param name The name of the option * @return the {@link org.apache.commons.cli2.Option} with the name, else null */ protected Option getCLIOption(String name) { for (Option option : options) { if (option.getPreferredName().equals(name)) { return option; } } return null; }
protected void doExecute(ExecutionContext ctx, CommandLine cl) throws Exception { String name = (String) cl.getValue(argName); if (name == null) { System.out.println("Hello, world."); } else { System.out.println("Hello, " + name + "."); } }
public boolean hasOption(String optName) { if (cmdLine == null) throw new IllegalStateException(); return this.cmdLine.hasOption(optName); }
public String getName() { return getCommand().getPreferredName(); }
static Double getDouble(CommandLine commandLine, Option option) { Object val = commandLine.getValue(option); if (val != null) { return Double.parseDouble(val.toString()); } return null; }
public boolean hasOption(Option opt) { if (cmdLine == null) throw new IllegalStateException(); return this.cmdLine.hasOption(opt); }
protected void doExecute(ConsoleExecutionContext ctx, CommandLine cl) throws Exception { String path = (String) cl.getValue(argPath, "/"); ctx.cd(path); }
public boolean execute(ExecutionContext ctx, CommandLine cl) throws Exception { if (cl.hasOption(getCommand())) { doExecute(ctx, cl); return true; } else { return false; } }
protected void doExecute(ExecutionContext ctx, CommandLine cl) throws Exception { String cmd = (String) cl.getValue(argCommand); ctx.printHelp(cmd); }
public boolean execute(ConsoleExecutionContext ctx, CommandLine cl) throws Exception { if (cl.hasOption(getCommand())) { doExecute(ctx, cl); return true; } else { return false; } }
protected void doExecute(ConsoleExecutionContext ctx, CommandLine cl) throws Exception { String macro = (String) cl.getValue(argMacro); String cmd = ctx.getProperty("macro." + macro); if (cmd == null) { throw new ExecutionException("Macro " + macro + " does not exist."); } ctx.execute(cmd); }