Optique 0.5.0: Enhanced error handling and message customization

洪 民憙 (Hong Minhee) @hongminhee@hackers.pub

Optique 0.5.0 is now available, bringing enhancements to error handling, help text generation, and overall developer experience while maintaining full backward compatibility. The update introduces better code organization by refactoring the large `@optique/core/parser` module into three focused modules: `@optique/core/primitives`, `@optique/core/modifiers`, and `@optique/core/constructs`. Error handling is improved with automatic conversion of default value callback errors into parser-level errors, and the new `WithDefaultError` class allows for structured error messages. Customization of default values in help text is now possible via an optional third parameter to `withDefault()`, enabling descriptive text instead of actual values. Additionally, the release provides comprehensive error message customization across all parser types and combinators, allowing context-specific feedback. These improvements aim to make Optique more user-friendly, especially for building CLI applications that require clear error messages and helpful documentation, making this release a significant step forward for developers using Optique.

Read more →
5

If you have a fediverse account, you can quote this article from your own instance. Search https://hackers.pub/ap/articles/019975b3-b32a-7d0f-b15d-611d1895b480 on your instance and quote it. (Note that quoting is not supported in Mastodon.)

Optique 0.5.0 is out! Enhanced error handling and message customization for TypeScript CLI parsing.

Key improvements:

  • Fully customizable error messages
  • Automatic error conversion for withDefault callbacks
  • Better help text and module organization
  • 100% backward compatible
4