zenodraft
Version:
CLI to manage depositions on Zenodo and Zenodo Sandbox
38 lines (37 loc) • 2.08 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { helpers_get_access_token_from_environment } from '../../lib/helpers/get-access-token-from-environment';
import { metadata_update } from '../../lib/metadata/update';
import { sandboxOption, verboseOption } from '../../lib/helpers/options';
import { tokensHelpText } from '../../lib/helpers/tokens-help-text';
import * as commander from 'commander';
export const metadata_update_command = () => {
return new commander.Command()
.name('update')
.arguments('<version_id> <local_filename>')
.description('Update the metadata of an existing deposition with id <version_id> using the metadata from <local_filename>.', {
version_id: 'id of the deposition whose metadata you want to update',
local_filename: 'filename of file holding the metadata in Zenodo metadata format'
})
.option(...sandboxOption)
.option(...verboseOption)
.action((version_id, local_filename, opts) => __awaiter(void 0, void 0, void 0, function* () {
const { sandbox, verbose } = opts;
try {
const access_token = helpers_get_access_token_from_environment(sandbox);
yield metadata_update(access_token, sandbox, version_id, local_filename, verbose);
}
catch (e) {
console.error(e.message);
process.exit(-1);
}
}))
.addHelpText('after', tokensHelpText);
};