json-type-cli
Version:
High-performance JSON Pointer implementation
24 lines (23 loc) • 913 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CliParamBool = void 0;
const json_patch_1 = require("json-joy/lib/json-patch");
const json_pointer_1 = require("@jsonjoy.com/json-pointer");
class CliParamBool {
constructor() {
this.param = 'bool';
this.short = 'b';
this.title = 'Set boolean value';
this.example = '--b/foo=true';
this.createInstance = (cli, pointer, rawValue) => new (class {
constructor() {
this.onRequest = async () => {
const value = Boolean(JSON.parse(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.CliParamBool = CliParamBool;