use of org.kohsuke.args4j.CmdLineParser in project buck by facebook.
the class StringSetOptionHandlerTest method testOptionSpecifiedMultipleTimes.
@Test
public void testOptionSpecifiedMultipleTimes() throws CmdLineException {
TestBean bean = new TestBean();
CmdLineParser parser = new CmdLineParser(bean);
parser.parseArgument("--option1", "a", "b", "--option2", "c", "d", "--option1", "e", "f", "--option2", "g", "h");
assertEquals(ImmutableSet.of("a", "b", "e", "f"), bean.getOption1());
assertEquals(ImmutableSet.of("c", "d", "g", "h"), bean.getOption2());
}
use of org.kohsuke.args4j.CmdLineParser in project hudson-2.x by hudson.
the class CLICommand method main.
public int main(List<String> args, Locale locale, InputStream stdin, PrintStream stdout, PrintStream stderr) {
this.stdin = new BufferedInputStream(stdin);
this.stdout = stdout;
this.stderr = stderr;
this.locale = locale;
this.channel = Channel.current();
registerOptionHandlers();
CmdLineParser p = new CmdLineParser(this);
// add options from the authenticator
SecurityContext sc = SecurityContextHolder.getContext();
Authentication old = sc.getAuthentication();
CliAuthenticator authenticator = Hudson.getInstance().getSecurityRealm().createCliAuthenticator(this);
new ClassParser().parse(authenticator, p);
try {
p.parseArgument(args.toArray(new String[args.size()]));
Authentication auth = authenticator.authenticate();
if (auth == Hudson.ANONYMOUS)
auth = loadStoredAuthentication();
// run the CLI with the right credential
sc.setAuthentication(auth);
if (!(this instanceof LoginCommand || this instanceof HelpCommand))
Hudson.getInstance().checkPermission(Hudson.READ);
return run();
} catch (CmdLineException e) {
stderr.println(e.getMessage());
printUsage(stderr, p);
return -1;
} catch (AbortException e) {
// signals an error without stack trace
stderr.println(e.getMessage());
return -1;
} catch (Exception e) {
e.printStackTrace(stderr);
return -1;
} finally {
// restore
sc.setAuthentication(old);
}
}
use of org.kohsuke.args4j.CmdLineParser in project pinot by linkedin.
the class DictionaryToRawIndexConverter method main.
/**
* Main method for the class.
*
* @param args Arguments for the converter
* @throws Exception
*/
public static void main(String[] args) throws Exception {
DictionaryToRawIndexConverter converter = new DictionaryToRawIndexConverter();
CmdLineParser parser = new CmdLineParser(converter);
parser.parseArgument(args);
converter.convert();
}
use of org.kohsuke.args4j.CmdLineParser in project pinot by linkedin.
the class ColumnarToStarTreeConverter method main.
/**
* Main driver for the converter class.
*
* @param args Command line arguments
* @throws Exception
*/
public static void main(String[] args) throws Exception {
ColumnarToStarTreeConverter converter = new ColumnarToStarTreeConverter();
CmdLineParser parser = new CmdLineParser(converter);
parser.parseArgument(args);
if (converter._help) {
printUsage();
return;
}
converter.convert();
}
use of org.kohsuke.args4j.CmdLineParser in project pinot by linkedin.
the class SegmentDumpTool method doMain.
public void doMain(String[] args) throws Exception {
CmdLineParser parser = new CmdLineParser(this);
parser.parseArgument(args);
File segmentDir = new File(segmentPath);
SegmentMetadata metadata = new SegmentMetadataImpl(segmentDir);
// All columns by default
if (columnNames == null) {
columnNames = new ArrayList<String>(metadata.getSchema().getColumnNames());
Collections.sort(columnNames);
}
IndexSegment indexSegment = Loaders.IndexSegment.load(segmentDir, ReadMode.mmap);
Map<String, Dictionary> dictionaries = new HashMap<String, Dictionary>();
Map<String, BlockSingleValIterator> iterators = new HashMap<String, BlockSingleValIterator>();
for (String columnName : columnNames) {
DataSource dataSource = indexSegment.getDataSource(columnName);
dataSource.open();
Block block = dataSource.nextBlock();
BlockValSet blockValSet = block.getBlockValueSet();
BlockSingleValIterator itr = (BlockSingleValIterator) blockValSet.iterator();
iterators.put(columnName, itr);
dictionaries.put(columnName, dataSource.getDictionary());
}
System.out.print("Doc\t");
for (String columnName : columnNames) {
System.out.print(columnName);
System.out.print("\t");
}
System.out.println();
for (int i = 0; i < indexSegment.getSegmentMetadata().getTotalDocs(); i++) {
System.out.print(i);
System.out.print("\t");
for (String columnName : columnNames) {
FieldSpec.DataType columnType = metadata.getSchema().getFieldSpecFor(columnName).getDataType();
BlockSingleValIterator itr = iterators.get(columnName);
Integer encodedValue = itr.nextIntVal();
Object value = dictionaries.get(columnName).get(encodedValue);
System.out.print(value);
System.out.print("\t");
}
System.out.println();
}
if (dumpStarTree) {
System.out.println();
File starTreeFile = new File(segmentDir, V1Constants.STAR_TREE_INDEX_FILE);
StarTreeInterf tree = StarTreeSerDe.fromFile(starTreeFile, ReadMode.mmap);
tree.printTree();
}
}
Aggregations