Search in sources :

Example 1 with ParseException

use of com.github.rvesse.airline.parser.errors.ParseException in project jena by apache.

the class RdfStats method run.

@Override
public int run(String[] args) {
    try (ColorizedOutputStream<BasicColor> error = new AnsiBasicColorizedOutputStream(new CloseShieldOutputStream(System.err))) {
        try {
            if (args.length == 0) {
                showUsage();
            }
            // Parse custom arguments
            RdfStats cmd = SingleCommand.singleCommand(RdfStats.class).parse(args);
            // Copy Hadoop configuration across
            cmd.setConf(this.getConf());
            // Show help if requested and exit with success
            if (cmd.helpOption.showHelpIfRequested()) {
                return 0;
            }
            // Run the command and exit with success
            cmd.run();
            return 0;
        } catch (ParseException e) {
            error.setForegroundColor(BasicColor.RED);
            error.println(e.getMessage());
            error.println();
        } catch (Throwable e) {
            error.setForegroundColor(BasicColor.RED);
            error.println(e.getMessage());
            e.printStackTrace(error);
            error.println();
        }
    }
    return 1;
}
Also used : BasicColor(com.github.rvesse.airline.io.colors.BasicColor) AnsiBasicColorizedOutputStream(com.github.rvesse.airline.io.output.AnsiBasicColorizedOutputStream) ParseException(com.github.rvesse.airline.parser.errors.ParseException) CloseShieldOutputStream(org.apache.commons.io.output.CloseShieldOutputStream)

Aggregations

BasicColor (com.github.rvesse.airline.io.colors.BasicColor)1 AnsiBasicColorizedOutputStream (com.github.rvesse.airline.io.output.AnsiBasicColorizedOutputStream)1 ParseException (com.github.rvesse.airline.parser.errors.ParseException)1 CloseShieldOutputStream (org.apache.commons.io.output.CloseShieldOutputStream)1