List of usage examples for org.apache.commons.cli CommandLine getOptionValues
public String[] getOptionValues(char opt)
From source file:ch.cyberduck.cli.SingleTransferItemFinder.java
@Override public Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote) { if (input.getOptionValues(action.name()).length == 2) { switch (action) { case download: return new DownloadTransferItemFinder().find(input, action, remote); case upload: case synchronize: return new UploadTransferItemFinder().find(input, action, remote); }/*from www. ja v a 2 s. c o m*/ } else { switch (action) { case upload: case synchronize: return Collections.emptySet(); } } // Relative to current working directory using prefix finder. return Collections .singleton(new TransferItem(remote, LocalFactory.get(prefixer.normalize(remote.getName())))); }
From source file:ch.cyberduck.cli.UploadTransferItemFinder.java
@Override public Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote) { final Local local = LocalFactory.get(input.getOptionValues(action.name())[1]); final Set<TransferItem> items = new HashSet<TransferItem>(); items.add(this.resolve(remote, local)); for (String arg : input.getArgs()) { items.add(this.resolve(remote, LocalFactory.get(arg))); }/* ww w. j a v a 2 s. com*/ return items; }
From source file:com.stratuscom.harvester.deployer.CommonsCLITest.java
/** * Test the implementation of our CommandLineParsers class. * @throws Exception /*from w w w . j a v a 2 s . co m*/ */ @Test public void testCommandLineParser() throws Exception { String[] args = { "-with", "reggie,test-module,A" }; CommandLine commandLine = CommandLineParsers.parseCommandLineAppRunnerLine(args); assertEquals(1, commandLine.getOptionValues(CommandLineParsers.WITH).length); }
From source file:ch.cyberduck.cli.DownloadTransferItemFinder.java
@Override public Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote) { final Local local = LocalFactory.get(input.getOptionValues(action.name())[1]); if (StringUtils.containsAny(remote.getName(), '*')) { // Treat asterisk as wildcard return Collections.singleton(new TransferItem(remote.getParent(), local)); }/* www . j a v a2s. co m*/ if (remote.isDirectory()) { // Remote path resolves to directory if (local.exists()) { return Collections.singleton(new TransferItem(remote, LocalFactory.get(local, remote.getName()))); } return Collections.singleton(new TransferItem(remote, local)); } // Remote path resolves to file if (local.isDirectory()) { // Append remote filename to local target return Collections.singleton(new TransferItem(remote, LocalFactory.get(local, remote.getName()))); } // Keep from input return Collections.singleton(new TransferItem(remote, local)); }
From source file:com.stratuscom.harvester.deployer.CommonsCLITest.java
/** * Test the implementation of our CommandLineParsers class. * @throws Exception /*from www . ja v a 2s . co m*/ */ @Test public void testAppArgs() throws Exception { String[] args = { "-with", "reggie,test-module,A", "a", "b" }; CommandLine commandLine = CommandLineParsers.parseCommandLineAppRunnerLine(args); assertEquals(1, commandLine.getOptionValues(CommandLineParsers.WITH).length); assertEquals("reggie,test-module,A", commandLine.getOptionValue(CommandLineParsers.WITH)); assertEquals(2, commandLine.getArgs().length); assertEquals("a", commandLine.getArgs()[0]); assertEquals("b", commandLine.getArgs()[1]); }
From source file:edu.cornell.med.icb.geo.tools.GDS2InsightfulMiner.java
private void printGroups(final CommandLine line) { final String[] groups = line.getOptionValues("g"); for (int i = 0; i < groups.length; i++) { final String group = groups[i]; System.err.println("group: " + group); }//from ww w . j a v a 2s .c o m }
From source file:edu.vt.middleware.ldap.cli.DeleteOperationCli.java
/** {@inheritDoc} */ @Override//from w ww.j a va2 s .c om protected void dispatch(final CommandLine line) throws Exception { if (line.hasOption(OPT_HELP)) { printHelp(); } else { delete(initConnectionFactory(line), line.getOptionValues(OPT_DN)); } }
From source file:info.mikaelsvensson.devtools.analysis.db2.Db2MonAnalyzer.java
@Override protected void runImpl(CommandLine commandLine, String[] filePaths, String reportFileName) throws Exception { String[] columnNames = commandLine.hasOption(OPT_ALL_COLUMN_NAMES) ? commandLine.getOptionValues(OPT_ALL_COLUMN_NAMES) : null;/*w w w . jav a2s . c o m*/ String[] outputColumnNames = commandLine.hasOption(OPT_OUTPUT_COLUMN_NAMES) ? commandLine.getOptionValues(OPT_OUTPUT_COLUMN_NAMES) : null; String[] idColumnNames = commandLine.hasOption(OPT_ID_COLUMN_NAMES) ? commandLine.getOptionValues(OPT_ID_COLUMN_NAMES) : null; String dateFormat = commandLine.getOptionValue(OPT_DATE_FORMAT); final String rowIdFilterPattern = commandLine.getOptionValue(OPT_ROW_ID_FILTER_PATTERN); final File[] files = new File[filePaths.length]; for (int i = 0; i < filePaths.length; i++) { files[i] = new File(filePaths[i]); } Db2MonLog log = Db2MonLog.fromLogFile(MINUTES_BETWEEN_SESSIONS, dateFormat, files); final Db2MonReportGenerator reportGenerator = new Db2MonReportGenerator(log, columnNames, outputColumnNames, idColumnNames, rowIdFilterPattern); reportGenerator.generateReport(new File(getFormattedString(reportFileName, files[0])), new PlainTextReportPrinter()); }
From source file:ch.cyberduck.cli.GlobTransferItemFinder.java
@Override public Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote) throws AccessDeniedException { if (input.getOptionValues(action.name()).length == 2) { final String path = input.getOptionValues(action.name())[1]; // This only applies to a shell where the glob is not already expanded into multiple arguments if (StringUtils.containsAny(path, '*', '?')) { final Local directory = LocalFactory.get(FilenameUtils.getFullPath(path)); if (directory.isDirectory()) { final PathMatcher matcher = FileSystems.getDefault() .getPathMatcher(String.format("glob:%s", FilenameUtils.getName(path))); final Set<TransferItem> items = new HashSet<TransferItem>(); for (Local file : directory.list(new NullFilter<String>() { @Override/*from ww w . j a va 2 s . c o m*/ public boolean accept(final String file) { try { return matcher.matches(Paths.get(file)); } catch (InvalidPathException e) { log.warn(String.format("Failure obtaining path for file %s", file)); } return false; } })) { items.add(new TransferItem(new Path(remote, file.getName(), EnumSet.of(Path.Type.file)), file)); } return items; } } } return new SingleTransferItemFinder().find(input, action, remote); }
From source file:net.ninjacat.stubborn.transform.Context.java
public Context(CommandLine commandLine) { sourceRoot = commandLine.getOptionValues(SOURCE); outputRoot = commandLine.getOptionValue(OUTPUT); rules = commandLine.getOptionValue(TRANSFORM_RULES); classPath = commandLine.hasOption(CLASSPATH) ? commandLine.getOptionValue(CLASSPATH) : ""; stripNonPublic = commandLine.hasOption(STRIP_NON_PUBLIC); stripFinals = commandLine.hasOption(STRIP_FINAL); stripFields = commandLine.hasOption(STRIP_FIELDS); ignoreDuplicateMatchers = commandLine.hasOption(IGNORE_DUPLICATE_MATCHERS); objectReturnStrategy = commandLine.hasOption(GENERATE_INSTANCES) ? ReturnObjects.Instance : ReturnObjects.Nulls;/* ww w .j a v a 2 s .com*/ int targetVersion = commandLine.hasOption(TARGET_VERSION) ? tryParseInt(commandLine.getOptionValue(TARGET_VERSION), 0) : 0; if (TARGET_VERSION_MAP.containsKey(targetVersion)) { target = TARGET_VERSION_MAP.get(targetVersion); } else { target = 0; } int loggingLevel = commandLine.hasOption(VERBOSE) ? 1 : 0; loggingLevel = tryParseInt(commandLine.getOptionValue(VERBOSE), loggingLevel); logLevel = loggingLevel; }