Skip to content

React to wrong library usage#1917

Closed
aweebit wants to merge 9 commits intotj:developfrom
aweebit:feature/strict
Closed

React to wrong library usage#1917
aweebit wants to merge 9 commits intotj:developfrom
aweebit:feature/strict

Conversation

@aweebit
Copy link
Copy Markdown
Contributor

@aweebit aweebit commented Jul 28, 2023

Update: Ideally, this PR should be superseded by #1938 and #1940. See comment for details.

Partially fixes #1916. I think it is a good idea to react to wrong library uses even if they have not been featured in many issues.

Why console.warn() and not throw from within parse() / parseAsync()?

Errors thrown from parse() / parseAsync() are expected to have originated in user-supplied code (argParsers, hooks, actions).

An alternative could be to console.error() and process.exit() with a non-zero exit code, effectively forbidding all wrong usage, but what I don't like is the discrepancy between this approach and how all other library errors are simply thrown and can be handled by the user.

ChangeLog

Added

  • Breaking: throw an error when trying to add a subcommand that already has a parent command
  • warnings about parse calls on subcommands
  • warnings about async hook and action calls made in .parse()

Peer PRs

Warnings need to be consistent with…

Parse call subroutine (_parseSubroutine()) needs to be consistent with…

Incompatible with…

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants