/** * Manage configuration settings. */ import { Args, Command, Flags } from "@oh-my-pi/pi-utils/cli"; import { configHelp as commandHelp } from "../cli/command-help"; import { type ConfigAction, type ConfigCommandArgs, type ConfigScope, runConfigCommand } from "../cli/config-cli"; import { initTheme } from "@oh-my-pi/pi-tui/theme"; const ACTIONS: ConfigAction[] = ["list", "get", "set", "reset", "path", "init-xdg"]; export default class Config extends Command { static description = commandHelp.description; static args = { action: Args.string({ description: "Config action", required: false, options: ACTIONS, }), key: Args.string({ description: "Setting key", required: false, }), value: Args.string({ description: "Value (for set/reset)", required: false, multiple: true, }), }; static flags = { json: Flags.boolean({ description: "Output JSON" }), scope: Flags.string({ description: 'With list: only the keys the "global" (config.yml in the agent dir) or "project" (/.omp) layer sets, as written', options: ["global", "project"], }), }; async run(): Promise { const { args, flags } = await this.parse(Config); const action = (args.action ?? "list") as ConfigAction; const value = Array.isArray(args.value) ? args.value.join(" ") : args.value; const cmd: ConfigCommandArgs = { action, key: args.key, value, flags: { json: flags.json, scope: flags.scope as ConfigScope | undefined, }, }; await initTheme(); await runConfigCommand(cmd); } }