Refine CLI version flag alias parsing and test expectations
This commit is contained in:
1 parent
ab440024b8
commit
802c32c6bd
2 files changed
+60
-10
No files matched your search
+16
-10
@@ -40,12 +40,13 @@ async function main() {
|
||||
const args = parseArgs(Bun.argv.slice(2));
|
||||
const [area, action, maybeName] = args.command;
|
||||
|
||||
if (!area || area === "help" || args.options.help) {
|
||||
printHelp();
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "version") {
|
||||
if (
|
||||
area === "version" ||
|
||||
area === "v" ||
|
||||
Boolean(args.options.version) ||
|
||||
Boolean(args.options.v) ||
|
||||
Boolean(args.options.V)
|
||||
) {
|
||||
printJson({
|
||||
name: "seal-home",
|
||||
version: VERSION
|
||||
@@ -53,6 +54,11 @@ async function main() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!area || area === "help" || args.options.help) {
|
||||
printHelp();
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "config" && action === "paths") {
|
||||
printJson({
|
||||
candidates: getEnterprisesDirCandidates()
|
||||
@@ -475,7 +481,7 @@ async function main() {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Unknown command: ${args.command.join(" ")}`);
|
||||
throw new Error(`Unknown command: ${args.command.join(" ")}. Run 'seal-home help' for available commands.`);
|
||||
}
|
||||
|
||||
async function runServiceCommand(action?: string) {
|
||||
@@ -1241,10 +1247,10 @@ function parseArgs(argv: string[]): ParsedArgs {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (arg.startsWith("--")) {
|
||||
const key = arg.slice(2);
|
||||
if (arg.startsWith("-")) {
|
||||
const key = arg.replace(/^-+/, "");
|
||||
const next = argv[index + 1];
|
||||
if (!next || next.startsWith("--")) {
|
||||
if (!next || next.startsWith("-")) {
|
||||
options[key] = true;
|
||||
} else {
|
||||
options[key] = next;
|
||||
|
||||
Reference in new issue
Block a user