CLI: add config path subcommand to print active config file path (#26256)
Merged via squash. Prepared head SHA: b11c593a34c5730f4244c054e1d1ab536953b0ef Co-authored-by: cyb1278588254 <48212932+cyb1278588254@users.noreply.github.com> Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com> Reviewed-by: @gumadeiras
This commit is contained in:
@@ -324,11 +324,22 @@ export async function runConfigUnset(opts: { path: string; runtime?: RuntimeEnv
|
||||
}
|
||||
}
|
||||
|
||||
export async function runConfigFile(opts: { runtime?: RuntimeEnv }) {
|
||||
const runtime = opts.runtime ?? defaultRuntime;
|
||||
try {
|
||||
const snapshot = await readConfigFileSnapshot();
|
||||
runtime.log(shortenHomePath(snapshot.path));
|
||||
} catch (err) {
|
||||
runtime.error(danger(String(err)));
|
||||
runtime.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
export function registerConfigCli(program: Command) {
|
||||
const cmd = program
|
||||
.command("config")
|
||||
.description(
|
||||
"Non-interactive config helpers (get/set/unset). Run without subcommand for the setup wizard.",
|
||||
"Non-interactive config helpers (get/set/unset/file). Run without subcommand for the setup wizard.",
|
||||
)
|
||||
.addHelpText(
|
||||
"after",
|
||||
@@ -390,4 +401,11 @@ export function registerConfigCli(program: Command) {
|
||||
.action(async (path: string) => {
|
||||
await runConfigUnset({ path });
|
||||
});
|
||||
|
||||
cmd
|
||||
.command("file")
|
||||
.description("Print the active config file path")
|
||||
.action(async () => {
|
||||
await runConfigFile({});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user