UNPKG

vlt

Version:
144 lines (142 loc) 4.18 kB
var global = globalThis; import {Buffer} from "node:buffer"; import {setTimeout,clearTimeout,setImmediate,clearImmediate,setInterval,clearInterval} from "node:timers"; import {createRequire as _vlt_createRequire} from "node:module"; var require = _vlt_createRequire(import.meta.filename); import { del, edit, get, list, set } from "./chunk-WJN6TZTJ.js"; import "./chunk-3SZCEJ7Q.js"; import "./chunk-FRVD5QAW.js"; import "./chunk-FZMPFIDM.js"; import "./chunk-SLTPNBLH.js"; import "./chunk-D36DAG56.js"; import "./chunk-LEKM5RQR.js"; import "./chunk-YWPMIBJS.js"; import "./chunk-5UBJ3ZBM.js"; import "./chunk-SGEQHKFC.js"; import { commandUsage } from "./chunk-2Y5QRO5N.js"; import "./chunk-VTABR43C.js"; import "./chunk-QAFV2NQX.js"; import "./chunk-VYJVN3B6.js"; import "./chunk-GADRCS54.js"; import "./chunk-GY4L7O2Y.js"; import "./chunk-3HSZY4YW.js"; import "./chunk-6YRWYWZQ.js"; import "./chunk-TJHWNOOA.js"; import "./chunk-L3TCSQZJ.js"; import "./chunk-3RABDTYN.js"; import "./chunk-264UXZEG.js"; import "./chunk-X4RDKJKD.js"; import { definition, isRecordField } from "./chunk-BNCOU5ZT.js"; import { error } from "./chunk-RV3EHS4P.js"; import "./chunk-AECDW3EJ.js"; // ../../src/cli-sdk/src/commands/config.ts var usage = () => commandUsage({ command: "config", usage: "<command> [flags]", description: "Work with vlt configuration", subcommands: { get: { usage: "<key> [<key> ...]", description: "Print the named config value" }, list: { description: "Print all configuration settings currently in effect" }, set: { usage: "<key>=<value> [<key>=<value> ...] [--config=<user | project>]", description: `Set config values. By default, these are written to the project config file, \`vlt.json\` in the root of the project. To set things for all projects, run with \`--config=user\`` }, del: { usage: "<key> [<key> ...] [--config=<user | project>]", description: `Delete the named config fields. If no values remain in the config file, delete the file as well. By default, operates on the \`vlt.json\` file in the root of the current project. To delete a config field from the user config file, specify \`--config=user\`.` }, edit: { usage: "[--config=<user | project>]", description: "Edit the configuration file" }, help: { usage: "[field ...]", description: `Get information about a config field, or show a list of known config field names.` } } }); var command = async (conf) => { const sub = conf.positionals[0]; switch (sub) { case "set": return set(conf); case "get": return get(conf); case "ls": case "list": return list(conf); case "edit": return edit(conf); case "help": return help(conf); case "del": return del(conf); default: { throw error("Unrecognized config command", { code: "EUSAGE", found: sub, validOptions: ["set", "get", "list", "edit", "help", "del"] }); } } }; var help = (conf) => { const j = definition.toJSON(); const fields = conf.positionals.slice(1); if (!fields.length) { return [ "Specify one or more options to see information:", ...Object.keys(j).sort((a, b) => a.localeCompare(b, "en")).map((c) => ` ${c}`) ].join("\n"); } const res = []; for (const f of fields) { const def = j[f]; if (!def) { res.push(`unknown config field: ${f}`); } else { const hint = def.hint ? `=<${def.hint}>` : ""; const type = isRecordField(f) ? "Record<string, string>" : def.type + (def.multiple ? "[]" : ""); res.push(`--${f}${hint}`); res.push(` type: ${type}`); if (def.default) { res.push(` default: ${JSON.stringify(def.default)}`); } if (def.description) { res.push(def.description); } } } return res.join("\n"); }; export { command, usage }; //# sourceMappingURL=config-YEHYFC62.js.map