Search in sources :

Example 1 with ExitCode

use of com.google.copybara.util.ExitCode in project copybara by google.

the class Main method run.

protected final ExitCode run(String[] args) {
    // We need a console before parsing the args because it could fail with wrong
    // arguments and we need to show the error.
    Console console = getConsole(args);
    // Configure logs location correctly before anything else. We want to write to the
    // correct location in case of any error.
    FileSystem fs = FileSystems.getDefault();
    try {
        configureLog(fs);
    } catch (IOException e) {
        handleUnexpectedError(console, e.getMessage(), args, e);
        return ExitCode.ENVIRONMENT_ERROR;
    }
    // This is useful when debugging user issues
    logger.info("Running: " + Joiner.on(' ').join(args));
    console.startupMessage(getVersion());
    ExitCode exitCode = runInternal(args, console, fs);
    try {
        shutdown(exitCode);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        handleUnexpectedError(console, "Execution was interrupted.", args, e);
    }
    return exitCode;
}
Also used : FileSystem(java.nio.file.FileSystem) ExitCode(com.google.copybara.util.ExitCode) AnsiConsole(com.google.copybara.util.console.AnsiConsole) Console(com.google.copybara.util.console.Console) LogConsole(com.google.copybara.util.console.LogConsole) IOException(java.io.IOException)

Aggregations

ExitCode (com.google.copybara.util.ExitCode)1 AnsiConsole (com.google.copybara.util.console.AnsiConsole)1 Console (com.google.copybara.util.console.Console)1 LogConsole (com.google.copybara.util.console.LogConsole)1 IOException (java.io.IOException)1 FileSystem (java.nio.file.FileSystem)1