fix(cli): show option descriptions in help output and move verify under config
This commit is contained in:
parent
6588fad461
commit
177c724fdf
4 changed files with 11 additions and 5 deletions
|
|
@ -8,6 +8,7 @@ interface OptionSpec {
|
||||||
type: "string" | "boolean";
|
type: "string" | "boolean";
|
||||||
short?: string;
|
short?: string;
|
||||||
default?: string | boolean | string[] | boolean[];
|
default?: string | boolean | string[] | boolean[];
|
||||||
|
description?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
type OptionsSpec = Record<string, OptionSpec>;
|
type OptionsSpec = Record<string, OptionSpec>;
|
||||||
|
|
@ -117,9 +118,10 @@ function showCommandHelp(
|
||||||
for (const [optName, optSpec] of Object.entries(targetConf.options)) {
|
for (const [optName, optSpec] of Object.entries(targetConf.options)) {
|
||||||
const short = optSpec.short ? `, -${optSpec.short}` : "";
|
const short = optSpec.short ? `, -${optSpec.short}` : "";
|
||||||
const typeHint = optSpec.type === "string" ? " <value>" : "";
|
const typeHint = optSpec.type === "string" ? " <value>" : "";
|
||||||
|
const desc = optSpec.description ?? "";
|
||||||
optionRows.push({
|
optionRows.push({
|
||||||
name: `--${optName}${short}${typeHint}`,
|
name: `--${optName}${short}${typeHint}`,
|
||||||
desc: "",
|
desc,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,7 +130,11 @@ function showCommandHelp(
|
||||||
|
|
||||||
lines.push(c.bold("Options:"));
|
lines.push(c.bold("Options:"));
|
||||||
for (const row of optionRows) {
|
for (const row of optionRows) {
|
||||||
lines.push(`${INDENT}${row.name.padEnd(colWidth)}`);
|
if (row.desc) {
|
||||||
|
lines.push(`${INDENT}${row.name.padEnd(colWidth)}${c.dim(row.desc)}`);
|
||||||
|
} else {
|
||||||
|
lines.push(`${INDENT}${row.name}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lines.push("");
|
lines.push("");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ export const commandRegistry = {
|
||||||
subcommands: {
|
subcommands: {
|
||||||
init: configInit.commandConfig,
|
init: configInit.commandConfig,
|
||||||
view: configView.commandConfig,
|
view: configView.commandConfig,
|
||||||
},
|
|
||||||
},
|
|
||||||
verify: verify.commandConfig,
|
verify: verify.commandConfig,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -214,7 +214,7 @@ async function verifyResults(
|
||||||
export const commandConfig: CommandConfig = {
|
export const commandConfig: CommandConfig = {
|
||||||
description: "Verify Myst configuration and connection to Forgejo",
|
description: "Verify Myst configuration and connection to Forgejo",
|
||||||
options: {
|
options: {
|
||||||
diagnostic: { type: "boolean" },
|
diagnostic: { type: "boolean", description: "Show diagnostic information for all checks" },
|
||||||
},
|
},
|
||||||
handler: verifyCommand,
|
handler: verifyCommand,
|
||||||
};
|
};
|
||||||
|
|
@ -44,7 +44,7 @@ export async function checkForgejoReachability(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkForgejoApi(
|
export async function checkForgejoApiAuthentication(
|
||||||
baseUrl: string,
|
baseUrl: string,
|
||||||
pat: string,
|
pat: string,
|
||||||
colorize = false,
|
colorize = false,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue