Skip to content

Commit ca126fa

Browse files
committed
Show an error message on unknown commands
1 parent 3ef10a9 commit ca126fa

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ program
6969
.option("--pretty", "pretty-print the output")
7070
.action(handleError(exportCommand));
7171

72+
// error on unknown commands
73+
program.on("command:*", () => {
74+
console.error(
75+
"Invalid command: %s\nSee --help for a list of available commands.",
76+
program.args.join(" ")
77+
);
78+
process.exit(1);
79+
});
80+
7281
function handleError(
7382
f: (...args: any[]) => Promise<void>
7483
): (...args: any[]) => Promise<void> {

0 commit comments

Comments
 (0)