use of com.beust.jcommander.JCommander in project midpoint by Evolveum.
the class Main method start.
private void start(String[] args) {
LOG.debug("Arguments: {}", Arrays.toString(args));
DefaultCommand def = new DefaultCommand();
JCommander commander = new JCommander(def);
for (Map.Entry<String, ActionValue> entry : ACTIONS.entrySet()) {
ActionValue value = entry.getValue();
commander.addCommand(entry.getKey(), value.command);
}
commander.parse(args);
String cmd = commander.getParsedCommand();
LOG.debug("Parsed command: '{}'", cmd);
if (StringUtils.isEmpty(cmd)) {
if (def.isVersion()) {
printVersion();
}
if (def.isHelp()) {
printHelp(commander);
}
return;
}
ActionValue actionValue = null;
for (Map.Entry<String, ActionValue> entry : ACTIONS.entrySet()) {
if (cmd != null && cmd.equals(entry.getKey())) {
actionValue = entry.getValue();
break;
}
}
if (actionValue == null) {
printHelp(commander);
return;
}
try {
LOG.debug("Executing action {} with params {}", actionValue.action.getSimpleName(), actionValue.command);
Action action = createAction(actionValue.action, actionValue.command, commander);
action.execute();
} catch (Exception ex) {
handleError(ex);
}
}
use of com.beust.jcommander.JCommander in project intellij-community by JetBrains.
the class RemoteTestNGStarter method main.
public static void main(String[] args) throws Exception {
int i = 0;
String param = null;
String commandFileName = null;
String workingDirs = null;
Vector resultArgs = new Vector();
for (; i < args.length; i++) {
String arg = args[i];
if (arg.startsWith("@name")) {
param = arg.substring(5);
continue;
} else if (arg.startsWith("@w@")) {
workingDirs = arg.substring(3);
continue;
} else if (arg.startsWith("@@@")) {
commandFileName = arg.substring(3);
continue;
} else if (arg.startsWith(ForkedDebuggerHelper.DEBUG_SOCKET)) {
continue;
} else if (arg.startsWith(SOCKET)) {
final int port = Integer.parseInt(arg.substring(SOCKET.length()));
try {
//start collecting tests
final Socket socket = new Socket(InetAddress.getByName("127.0.0.1"), port);
final DataInputStream os = new DataInputStream(socket.getInputStream());
try {
//wait for ready flag
os.readBoolean();
} finally {
os.close();
}
} catch (IOException e) {
e.printStackTrace();
}
//do not add socket to actual params
continue;
} else if (arg.equals("-temp")) {
break;
}
resultArgs.add(arg);
}
final File temp = new File(args[++i]);
final BufferedReader reader = new BufferedReader(new FileReader(temp));
final List newArgs = new ArrayList();
try {
final String cantRunMessage = "CantRunException";
while (true) {
String line = reader.readLine();
while (line == null) {
line = reader.readLine();
}
if (line.startsWith(cantRunMessage) && !new File(line).exists()) {
System.err.println(line.substring(cantRunMessage.length()));
while (true) {
line = reader.readLine();
if (line == null || line.equals("end"))
break;
System.err.println(line);
}
System.exit(1);
return;
}
if (line.equals("end"))
break;
newArgs.add(line);
}
} finally {
reader.close();
}
resultArgs.addAll(newArgs);
if (commandFileName != null) {
if (workingDirs != null && new File(workingDirs).length() > 0) {
System.exit(new TestNGForkedSplitter(workingDirs, newArgs).startSplitting(args, param, commandFileName, null));
return;
}
}
final IDEARemoteTestNG testNG = new IDEARemoteTestNG(param);
CommandLineArgs cla = new CommandLineArgs();
new JCommander(Collections.singletonList(cla), (String[]) resultArgs.toArray(new String[resultArgs.size()]));
testNG.configure(cla);
testNG.run();
}
use of com.beust.jcommander.JCommander in project zxing by zxing.
the class CommandLineEncoder method main.
public static void main(String[] args) throws Exception {
EncoderConfig config = new EncoderConfig();
JCommander jCommander = new JCommander(config, args);
jCommander.setProgramName(CommandLineEncoder.class.getSimpleName());
if (config.help) {
jCommander.usage();
return;
}
String outFileString = config.outputFileBase;
if (EncoderConfig.DEFAULT_OUTPUT_FILE_BASE.equals(outFileString)) {
outFileString += '.' + config.imageFormat.toLowerCase(Locale.ENGLISH);
}
Map<EncodeHintType, Object> hints = new EnumMap<>(EncodeHintType.class);
if (config.errorCorrectionLevel != null) {
hints.put(EncodeHintType.ERROR_CORRECTION, config.errorCorrectionLevel);
}
BitMatrix matrix = new MultiFormatWriter().encode(config.contents.get(0), config.barcodeFormat, config.width, config.height, hints);
MatrixToImageWriter.writeToPath(matrix, config.imageFormat, Paths.get(outFileString));
}
use of com.beust.jcommander.JCommander in project smali by JesusFreke.
the class ListCommand method setupCommand.
@Override
protected void setupCommand(JCommander jc) {
List<JCommander> hierarchy = getCommandHierarchy();
ExtendedCommands.addExtendedCommand(jc, new ListStringsCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListMethodsCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListFieldsCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListTypesCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListClassesCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListDexCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListVtablesCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListFieldOffsetsCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListDependenciesCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListHelpCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListHlepCommand(hierarchy));
}
use of com.beust.jcommander.JCommander in project smali by JesusFreke.
the class ListCommand method run.
@Override
public void run() {
JCommander jc = getJCommander();
if (help || jc.getParsedCommand() == null) {
usage();
return;
}
Command command = (Command) jc.getCommands().get(jc.getParsedCommand()).getObjects().get(0);
command.run();
}
Aggregations