Search in sources :

Example 1 with BasicColor

use of com.github.rvesse.airline.io.colors.BasicColor in project jena by apache.

the class RdfStats method main.

/**
     * Entry point method
     * 
     * @param args
     *            Arguments
     */
public static void main(String[] args) {
    try (ColorizedOutputStream<BasicColor> error = new AnsiBasicColorizedOutputStream(new CloseShieldOutputStream(System.err))) {
        try {
            // Run and exit with result code if no errors bubble up
            // Note that the exit code may still be a error code
            int res = ToolRunner.run(new Configuration(true), new RdfStats(), args);
            System.exit(res);
        } catch (Throwable e) {
            // This will only happen if Hadoop option parsing errors
            // The run() method will handle its error itself
            error.setForegroundColor(BasicColor.RED);
            error.println(e.getMessage());
            e.printStackTrace(error);
        }
    }
    // If any errors bubble up exit with non-zero code
    System.exit(1);
}
Also used : BasicColor(com.github.rvesse.airline.io.colors.BasicColor) AnsiBasicColorizedOutputStream(com.github.rvesse.airline.io.output.AnsiBasicColorizedOutputStream) Configuration(org.apache.hadoop.conf.Configuration) CloseShieldOutputStream(org.apache.commons.io.output.CloseShieldOutputStream)

Example 2 with BasicColor

use of com.github.rvesse.airline.io.colors.BasicColor 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)2 AnsiBasicColorizedOutputStream (com.github.rvesse.airline.io.output.AnsiBasicColorizedOutputStream)2 CloseShieldOutputStream (org.apache.commons.io.output.CloseShieldOutputStream)2 ParseException (com.github.rvesse.airline.parser.errors.ParseException)1 Configuration (org.apache.hadoop.conf.Configuration)1