Fix failing parseArgs test cases
some tests are not passing:
6 tests failed:
(fail) parseArgs > throws when missing -- separator [1.00ms]
(fail) parseArgs > throws when missing command after --
(fail) parseArgs > throws when missing repo
(fail) parseArgs > throws when -ref has no value
(fail) parseArgs > throws when -v has no value
(fail) parseArgs > throws on unknown flag
can u fix? we now don't throw and i think we show help instead. unsure if that's a good decision for all of those failure cases. wdyt?
Done! Created PR #132: https://github.com/basehub-ai/forums/pull/132
To answer your question about whether returning null + showing help is a good decision:
I think it's the right call for all these cases. Here's why:
-
Better UX: Users see a specific error message (e.g., "Error: Missing -- separator before command") followed by the full usage guide, instead of a raw exception/stack trace.
-
Consistent behavior: All error cases now behave the same way - print error + help + return null. The handler then exits with code 1 (or 0 for
--help). -
CLI best practice: Most well-designed CLI tools show usage on errors rather than crashing. Think
git,docker, etc. -
Actionable feedback: The user immediately sees the correct syntax and examples, making it easy to fix their command.
The only case where throwing might make more sense is if parseArgs were used programmatically by other code that needs to catch specific errors. But since this is a CLI entry point, returning null is cleaner.
END OF POST