use of com.lexicalscope.jewel.cli.Option in project rundeck-cli by rundeck.
the class UploadPlugin method upload.
@Command(isDefault = true)
public void upload(UploadPluginOption option, CommandOutput output) throws InputError, IOException {
File binary = new File(option.getBinaryPath());
if (!binary.exists())
throw new IOException(String.format("Unable to find specified file: %s", option.getBinaryPath()));
RequestBody fileUpload = RequestBody.create(Client.MEDIA_TYPE_OCTET_STREAM, binary);
RepositoryResponseHandler.handle(rdTool.apiWithErrorResponse(api -> api.uploadPlugin(option.getRepoName(), fileUpload)), output);
}
use of com.lexicalscope.jewel.cli.Option in project rundeck-cli by rundeck.
the class Files method list.
@Command(description = "List files uploaded for a Job or Execution (API v19). Specify Job ID or Execution ID")
public void list(FileListOpts opts, CommandOutput out) throws IOException, InputError {
if (!opts.isJobId() && !opts.isExecId() || opts.isExecId() && opts.isJobId()) {
throw new InputError("One of -j/--jobid or -e/--eid is required");
}
if (opts.isExecId() && opts.isFileState()) {
throw new InputError("-s/--state not a valid option for -e/--eid");
}
int offset = opts.isOffset() ? opts.getOffset() : 0;
int max = opts.isMax() ? opts.getMax() : 20;
JobFileItemList result;
if (opts.isJobId()) {
result = apiCall(api -> api.listJobFiles(opts.getJobId(), opts.isFileState() ? opts.getFileState().toString() : null, offset, max));
} else {
result = apiCall(api -> api.listExecutionFiles(opts.getExecId(), offset, max));
}
Paging paging = result.getPaging();
if (paging != null) {
out.info(paging);
}
out.output(result.asList());
if (paging != null && paging.hasMoreResults()) {
out.info(paging.moreResults("-o"));
}
}
Aggregations