What's happening
If you pass an unrecognized flag (e.g. metacall-deploy --not-a-real-flag),
the CLI prints a warning and the help text, but exits with code 0.
This breaks any CI pipeline or shell script that checks the exit code to detect invalid usage.
Steps to reproduce
metacall-deploy --not-a-real-flag
echo $?
What you'd expect
Exit code 1 (or any non-zero) when an unknown flag is passed.
What actually happens
process.exit(0) because handleUnknownArgs() calls printHelp() which always exits with ErrorCode.Ok.
Relevant files:
src/cli/unknown.ts// always calls printHelp()
src/help.ts // always exits with ErrorCode.Ok
The fix
Add an optional exit code param to printHelp:
// src/help.ts
export const printHelp = (exitCode = ErrorCode.Ok) => {
// ...
process.exit(exitCode);
};
Then call it with 1 from the unknown-args path:
// src/cli/unknown.ts
printHelp(1);
Keep 0 only for explicit --help. Happy to fix this.
What's happening
If you pass an unrecognized flag (e.g.
metacall-deploy --not-a-real-flag),the CLI prints a warning and the help text, but exits with code
0.This breaks any CI pipeline or shell script that checks the exit code to detect invalid usage.
Steps to reproduce
What you'd expect
Exit code
1(or any non-zero) when an unknown flag is passed.What actually happens
process.exit(0)becausehandleUnknownArgs()callsprintHelp()which always exits withErrorCode.Ok.Relevant files:
src/cli/unknown.ts// always callsprintHelp()src/help.ts// always exits withErrorCode.OkThe fix
Add an optional exit code param to
printHelp:Then call it with
1from the unknown-args path:Keep
0only for explicit--help. Happy to fix this.