UNPKG

@oada/cli

Version:

CLI OADA client

29 lines 1.01 kB
import Command from '../../BaseCommand.js'; import getConn from '../../connections.js'; import { input } from '../../io.js'; import { shell } from '../../highlight.js'; const examples = [ shell `$ oada cp /resources/foo /bookmarks/foo`, shell `$ oada cp /resources/foo1 /resources/foo2 /bookmarks/foo/`, ]; class Copy extends Command { async run() { const { argv: paths } = await this.parse(Copy); const conn = getConn(this.iconfig); const path = paths.pop(); const method = path.endsWith('/') ? 'post' : 'put'; 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, data: data }); } }); } } } Copy.description = 'perform an "OADA copy"'; Copy.aliases = ['cp']; Copy.examples = examples; Copy.strict = false; export default Copy; //# sourceMappingURL=copy.js.map