UNPKG

@oada/cli

Version:

CLI OADA client

40 lines 1.62 kB
import { Flags } from '@oclif/core'; import { input, loadFile } from '../io.js'; import Command from '../BaseCommand.js'; import getConn from '../connections.js'; import { shell } from '../highlight.js'; const [put, post] = ['put', 'post'].map((method) => { var _a; const METH = method.toUpperCase(); const examples = method === 'put' ? [shell `$ oada put - /bookmarks/ <<< '{"a": 1}'`] : [shell `$ oada post - /bookmarks/ <<< '{"a": 1}{"b": true}'`]; return _a = class PutPost extends Command { async run() { const { argv: paths, flags: { tree: treefile }, } = await this.parse(PutPost); const conn = getConn(this.iconfig); const path = paths.pop(); const tree = treefile ? (await loadFile(treefile)) : undefined; for await (const file of paths) { await input(conn, `${file}`, this.iconfig, async function* (source) { for await (const data of source) { await conn[method]({ path, tree, data: data }); } }); } } }, _a.description = `Perform an OADA ${METH}`, _a.aliases = [method.slice(0, 2), METH], _a.examples = examples, _a.flags = { tree: Flags.string({ char: 'T', description: `file containing an OADA tree to use for a tree ${METH}`, }), }, _a.strict = false, _a; }); export { put, post }; //# sourceMappingURL=putpost.js.map