Search in sources :

Example 1 with CatCommand

use of com.google.devtools.build.remote.client.RemoteClientOptions.CatCommand in project tools_remote by bazelbuild.

the class RemoteClient method selectAndPerformCommand.

public static void selectAndPerformCommand(String[] args) throws Exception {
    AuthAndTLSOptions authAndTlsOptions = new AuthAndTLSOptions();
    RemoteOptions remoteOptions = new RemoteOptions();
    RemoteClientOptions remoteClientOptions = new RemoteClientOptions();
    LsCommand lsCommand = new LsCommand();
    LsOutDirCommand lsOutDirCommand = new LsOutDirCommand();
    GetDirCommand getDirCommand = new GetDirCommand();
    GetOutDirCommand getOutDirCommand = new GetOutDirCommand();
    CatCommand catCommand = new CatCommand();
    FailedActionsCommand failedActionsCommand = new FailedActionsCommand();
    ShowActionCommand showActionCommand = new ShowActionCommand();
    ShowActionResultCommand showActionResultCommand = new ShowActionResultCommand();
    PrintLogCommand printLogCommand = new PrintLogCommand();
    RunCommand runCommand = new RunCommand();
    JCommander optionsParser = JCommander.newBuilder().programName("remote_client").addObject(authAndTlsOptions).addObject(remoteOptions).addObject(remoteClientOptions).addCommand("ls", lsCommand).addCommand("lsoutdir", lsOutDirCommand).addCommand("getdir", getDirCommand).addCommand("getoutdir", getOutDirCommand).addCommand("cat", catCommand).addCommand("show_action", showActionCommand, "sa").addCommand("show_action_result", showActionResultCommand, "sar").addCommand("printlog", printLogCommand).addCommand("run", runCommand).addCommand("failed_actions", failedActionsCommand).build();
    try {
        optionsParser.parse(args);
    } catch (ParameterException e) {
        System.err.println("Unable to parse options: " + e.getLocalizedMessage());
        optionsParser.usage();
        System.exit(1);
    }
    if (remoteClientOptions.help) {
        optionsParser.usage();
        return;
    }
    if (optionsParser.getParsedCommand() == null) {
        System.err.println("No command specified.");
        optionsParser.usage();
        System.exit(1);
    }
    switch(optionsParser.getParsedCommand()) {
        case "printlog":
            doPrintLog(remoteClientOptions.grpcLog, printLogCommand);
            break;
        case "ls":
            doLs(lsCommand, makeClientWithOptions(remoteOptions, authAndTlsOptions));
            break;
        case "lsoutdir":
            doLsOutDir(lsOutDirCommand, makeClientWithOptions(remoteOptions, authAndTlsOptions));
            break;
        case "getdir":
            doGetDir(getDirCommand, makeClientWithOptions(remoteOptions, authAndTlsOptions));
            break;
        case "getoutdir":
            doGetOutDir(getOutDirCommand, makeClientWithOptions(remoteOptions, authAndTlsOptions));
            break;
        case "cat":
            doCat(catCommand, makeClientWithOptions(remoteOptions, authAndTlsOptions));
            break;
        case "show_action":
            doShowAction(showActionCommand, makeClientWithOptions(remoteOptions, authAndTlsOptions));
            break;
        case "show_action_result":
            doShowActionResult(showActionResultCommand, makeClientWithOptions(remoteOptions, authAndTlsOptions));
            break;
        case "run":
            doRun(remoteClientOptions.grpcLog, runCommand, makeClientWithOptions(remoteOptions, authAndTlsOptions));
            break;
        case "failed_actions":
            doFailedActions(remoteClientOptions.grpcLog, failedActionsCommand);
            break;
        default:
            throw new IllegalArgumentException("Unknown command.");
    }
}
Also used : GetOutDirCommand(com.google.devtools.build.remote.client.RemoteClientOptions.GetOutDirCommand) ShowActionCommand(com.google.devtools.build.remote.client.RemoteClientOptions.ShowActionCommand) RunCommand(com.google.devtools.build.remote.client.RemoteClientOptions.RunCommand) PrintLogCommand(com.google.devtools.build.remote.client.RemoteClientOptions.PrintLogCommand) LsCommand(com.google.devtools.build.remote.client.RemoteClientOptions.LsCommand) GetDirCommand(com.google.devtools.build.remote.client.RemoteClientOptions.GetDirCommand) FailedActionsCommand(com.google.devtools.build.remote.client.RemoteClientOptions.FailedActionsCommand) JCommander(com.beust.jcommander.JCommander) LsOutDirCommand(com.google.devtools.build.remote.client.RemoteClientOptions.LsOutDirCommand) CatCommand(com.google.devtools.build.remote.client.RemoteClientOptions.CatCommand) ParameterException(com.beust.jcommander.ParameterException) ShowActionResultCommand(com.google.devtools.build.remote.client.RemoteClientOptions.ShowActionResultCommand)

Aggregations

JCommander (com.beust.jcommander.JCommander)1 ParameterException (com.beust.jcommander.ParameterException)1 CatCommand (com.google.devtools.build.remote.client.RemoteClientOptions.CatCommand)1 FailedActionsCommand (com.google.devtools.build.remote.client.RemoteClientOptions.FailedActionsCommand)1 GetDirCommand (com.google.devtools.build.remote.client.RemoteClientOptions.GetDirCommand)1 GetOutDirCommand (com.google.devtools.build.remote.client.RemoteClientOptions.GetOutDirCommand)1 LsCommand (com.google.devtools.build.remote.client.RemoteClientOptions.LsCommand)1 LsOutDirCommand (com.google.devtools.build.remote.client.RemoteClientOptions.LsOutDirCommand)1 PrintLogCommand (com.google.devtools.build.remote.client.RemoteClientOptions.PrintLogCommand)1 RunCommand (com.google.devtools.build.remote.client.RemoteClientOptions.RunCommand)1 ShowActionCommand (com.google.devtools.build.remote.client.RemoteClientOptions.ShowActionCommand)1 ShowActionResultCommand (com.google.devtools.build.remote.client.RemoteClientOptions.ShowActionResultCommand)1