@Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final String jobIdString = options.getString(jobArg.getDest()); final Map<JobId, Job> jobs = client.jobs(jobIdString).get(); if (jobs.size() == 0) { if (!json) { out.printf("Unknown job: %s%n", jobIdString); } else { final JobDeployResponse jobDeployResponse = new JobDeployResponse(JobDeployResponse.Status.JOB_NOT_FOUND, null, null); out.print(jobDeployResponse.toJsonString()); } return 1; } else if (jobs.size() > 1) { if (!json) { out.printf("Ambiguous job reference: %s%n", jobIdString); } else { final JobDeployResponse jobDeployResponse = new JobDeployResponse(JobDeployResponse.Status.AMBIGUOUS_JOB_REFERENCE, null, null); out.print(jobDeployResponse.toJsonString()); } return 1; } final Job job = Iterables.getOnlyElement(jobs.values()); return runWithJob(options, client, out, json, job, stdin); }
out.printf("done%n"); } else { out.print(result.toJsonString()); out.printf("failed: %s%n", result); } else { out.print(result.toJsonString());
@Override int run(final Namespace options, final HeliosClient client, final PrintStream out, final boolean json, final BufferedReader stdin) throws ExecutionException, InterruptedException, IOException { final String jobIdString = options.getString(jobArg.getDest()); final Map<JobId, Job> jobs = client.jobs(jobIdString).get(); if (jobs.size() == 0) { if (!json) { out.printf("Unknown job: %s%n", jobIdString); } else { JobDeployResponse jobDeployResponse = new JobDeployResponse(JobDeployResponse.Status.JOB_NOT_FOUND, null, null); out.printf(jobDeployResponse.toJsonString()); } return 1; } else if (jobs.size() > 1) { if (!json) { out.printf("Ambiguous job reference: %s%n", jobIdString); } else { JobDeployResponse jobDeployResponse = new JobDeployResponse(JobDeployResponse.Status.AMBIGUOUS_JOB_REFERENCE, null, null); out.printf(jobDeployResponse.toJsonString()); } return 1; } final JobId jobId = Iterables.getOnlyElement(jobs.keySet()); return runWithJobId(options, client, out, json, jobId, stdin); }
out.printf("done%n"); } else { out.printf(result.toJsonString()); out.printf("failed: %s%n", result); } else { out.printf(result.toJsonString());