in parquet-cli/src/main/java/org/apache/parquet/cli/Main.java [113:184]
public int run(String[] args) throws Exception {
try {
jc.parse(args);
} catch (MissingCommandException e) {
console.error(e.getMessage());
return 1;
} catch (ParameterException e) {
help.setProgramName(programName);
String cmd = jc.getParsedCommand();
if (args.length == 1) { // i.e., just the command (missing required arguments)
help.helpCommands.add(cmd);
help.run();
return 1;
} else { // check for variants like 'cmd --help' etc.
for (String arg : args) {
if (HELP_ARGS.contains(arg)) {
help.helpCommands.add(cmd);
help.run();
return 0;
}
}
}
console.error(e.getMessage());
return 1;
}
help.setProgramName(programName);
// configure log4j
if (debug) {
org.apache.log4j.Logger console = org.apache.log4j.Logger.getLogger(Main.class);
console.setLevel(Level.DEBUG);
}
String parsed = jc.getParsedCommand();
if (parsed == null) {
help.run();
return 1;
} else if ("help".equals(parsed)) {
return help.run();
}
Command command = (Command) jc.getCommands().get(parsed).getObjects().get(0);
if (command == null) {
help.run();
return 1;
}
try {
if (command instanceof Configurable) {
((Configurable) command).setConf(getConf());
}
return command.run();
} catch (IllegalArgumentException e) {
if (debug) {
console.error("Argument error", e);
} else {
console.error("Argument error: {}", e.getMessage());
}
return 1;
} catch (IllegalStateException e) {
if (debug) {
console.error("State error", e);
} else {
console.error("State error: {}", e.getMessage());
}
return 1;
} catch (Exception e) {
console.error("Unknown error", e);
return 1;
}
}