UNPKG

@oada/cli

Version:

CLI OADA client

34 lines 1.14 kB
import Command from '../../BaseCommand.js'; import getConn from '../../connections.js'; import { shell } from '../../highlight.js'; const examples = [ shell `$ oada mv /resources/foo /bookmarks/foo`, shell `$ oada mv /resources/foo1 /resources/foo2 /bookmarks/foo/`, ]; class Move extends Command { async run() { const { argv: paths } = await this.parse(Move); const conn = getConn(this.iconfig); const path = paths.pop(); const method = path.endsWith('/') ? 'post' : 'put'; for (const file of paths) { try { const { data } = await conn.get({ path: `${file}` }); if (!data) { throw new Error(`No data found at ${file}`); } await conn[method]({ path, data }); await conn.delete({ path: `${file}` }); } catch (error) { console.error(error); } } } } Move.description = 'perform an "OADA move"'; Move.aliases = ['mv']; Move.examples = examples; Move.strict = false; export default Move; //# sourceMappingURL=move.js.map