com.sampullara.cli.Args Java Examples
The following examples show how to use
com.sampullara.cli.Args.
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: ArgsParser.java From obevo with Apache License 2.0 | 6 votes |
public <T> T parse(String[] args, T inputArgs, Function<? super T, String> validationFunction) { try { List<String> extraArgs = Args.parse(inputArgs, args); if (extraArgs.size() > 0) { printUsageAndExit(inputArgs, "Passed in unnecessary args: " + StringUtils.join(extraArgs, "; ")); } String validationMessage = validationFunction.valueOf(inputArgs); if (validationMessage != null) { printUsageAndExit(inputArgs, validationMessage); } } catch (IllegalArgumentException exc) { printUsageAndExit(inputArgs, ExceptionUtils.getStackTrace(exc)); } LOG.info("Arguments parsed: " + inputArgs.toString()); return inputArgs; }
Example #2
Source File: ArchivaCli.java From archiva with Apache License 2.0 | 6 votes |
public static void main( String[] args ) throws Exception { Commands command = new Commands(); try { Args.parse( command, args ); } catch ( IllegalArgumentException e ) { LOGGER.error( e.getMessage(), e ); Args.usage( command ); return; } ArchivaCli cli = new ArchivaCli(); try { cli.execute( command ); } finally { cli.destroy(); } }
Example #3
Source File: ItemAttributesImporter.java From seldon-server with Apache License 2.0 | 5 votes |
/** * @param args * @throws InterruptedException * @throws FileNotFoundException */ public static void main(String[] args) throws InterruptedException, FileNotFoundException { FailFast failFast = new FailFast(Thread.currentThread()); { // Fail Fast thread Thread fail_fast_thread = new Thread(failFast); fail_fast_thread.setName("fail_fast_thread"); fail_fast_thread.start(); } try { Args.parse(ItemAttributesImporter.class, args); { // Determine opMode by checking for urlFile if (urlFile !=null) { opMode = OperationMode.OPERATION_MODE_FILE_IMPORTER; } } DefaultApiClient client = new DefaultApiClient(apiUrl,consumerKey,consumerSecret,API_TIMEOUT); ItemAttributesImporter fixer = new ItemAttributesImporter(client); fixer.setFailFast(failFast); fixer.run(); } catch (IllegalArgumentException e) { e.printStackTrace(); Args.usage(ItemAttributesImporter.class); } }
Example #4
Source File: FileItemAttributesImporter.java From seldon-server with Apache License 2.0 | 5 votes |
/** * @param args * @throws InterruptedException * @throws FileNotFoundException */ public static void main(String[] args) throws InterruptedException, FileNotFoundException { FailFast failFast = new FailFast(Thread.currentThread()); { // Fail Fast thread Thread fail_fast_thread = new Thread(failFast); fail_fast_thread.setName("fail_fast_thread"); fail_fast_thread.start(); } try { Args.parse(FileItemAttributesImporter.class, args); DefaultApiClient client = new DefaultApiClient(apiUrl,consumerKey,consumerSecret,API_TIMEOUT); FileItemAttributesImporter fixer = new FileItemAttributesImporter(client); fixer.setFailFast(failFast); fixer.run(); } catch (IllegalArgumentException e) { e.printStackTrace(); Args.usage(FileItemAttributesImporter.class); } }
Example #5
Source File: ExpandQuery.java From word2vec-query-expansion with Apache License 2.0 | 5 votes |
/** * @param args * , three arguments, whether all the words are combined or separated * @throws IOException * @throws OutOfVocabularyException */ public static void main(String[] args) throws VectorsException, IOException { // arguments try { Args.parse(ExpandQuery.class, args); } catch (IllegalArgumentException e) { Args.usage(ExpandQuery.class); System.exit(1); } QueryExpander queryExpander = new QueryExpander(new Vectors(new FileInputStream(new File(vectorsFileName))), combineTerms, QueryExpander.TermSelection.valueOf(termSelectionString)); // read queries, one per line BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(inputFileName), "UTF-8")); String line = br.readLine(); line = br.readLine(); while (line != null) { // qid and query String[] parts = line.split(","); String qid = parts[0]; String query = parts[1]; List<Distance.ScoredTerm> expansion = queryExpander.expand(query); PrintWriter pw = new PrintWriter(new FileWriter(new File(outputFolderName, qid + ".terms"))); for (Distance.ScoredTerm scoredTerm : expansion) pw.println(scoredTerm.getTerm() + "\t" + scoredTerm.getScore()); pw.close(); line = br.readLine(); } br.close(); }
Example #6
Source File: ArchivaCli.java From archiva with Apache License 2.0 | 5 votes |
private void execute( Commands command ) throws Exception { if ( command.help ) { Args.usage( command ); } else if ( command.version ) { LOGGER.info( "Version: {}", getVersion() ); } else if ( command.convert ) { LOGGER.error( "Conversion is not available anymore" ); } else if ( command.scan ) { if ( command.repository == null ) { LOGGER.error( "The repository must be specified." ); Args.usage( command ); return; } doScan( command.repository, command.consumers.split( "," ) ); } else if ( command.listConsumers ) { dumpAvailableConsumers(); } else { Args.usage( command ); } }
Example #7
Source File: ArgsParser.java From obevo with Apache License 2.0 | 4 votes |
private static <T> void printUsageAndExit(T inputArgs, String message) { Args.usage(inputArgs); System.err.println(message); System.exit(-1); }