UNPKG

json-type-cli

Version:

High-performance JSON Pointer implementation

24 lines (23 loc) 885 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CliParamStr = void 0; const json_patch_1 = require("json-joy/lib/json-patch"); const json_pointer_1 = require("@jsonjoy.com/json-pointer"); class CliParamStr { constructor() { this.param = 'str'; this.short = 's'; this.title = 'Set string value'; this.example = '--s/foo=abc'; this.createInstance = (cli, pointer, rawValue) => new (class { constructor() { this.onRequest = async () => { const value = String(rawValue); const path = (0, json_pointer_1.toPath)(pointer); cli.request = (0, json_patch_1.applyPatch)(cli.request, [{ op: 'add', path, value }], { mutate: true }).doc; }; } })(); } } exports.CliParamStr = CliParamStr;