Skip to content

[FEATURE] Add a handler for *unknown* options, analogous to invalidHandler #41

Closed

Description

@mklement0

Currently (v3.0.1), nopt invariably accepts unknown options and simply adds them to the object returned.

However, a typical use case for a CLI is to abort processing in case an unknown option is specified.

Thus, an .unknownHandler property specifying a function to call on encountering an unknown option would be handy - analogous to the existing .invalidHandler property for handling invalid option values.

I'd be happy to implement this.

Activity

  1. binki commented on May 30, 2017

    @binki

    IMO, default behavior should be to throw and an .unknownHandler should be used to either change the behavior or print out a prettier message.

  2. changed the title [-]Suggestion: add a handler for *unknown* options, analogous to `invalidHandler`[/-] [+][FEATURE] Add a handler for *unknown* options, analogous to `invalidHandler`[/+] on Jul 28, 2022
  3. added
    Enhancement
    on Jul 28, 2022
  4. self-assigned this
    on Jan 8, 2025
  5. wraithgar commented on Jan 8, 2025

    @wraithgar
    Contributor
  6. wraithgar commented on Jan 21, 2025

    @wraithgar
    Contributor

    This is now included in [email protected]

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

Metadata

Metadata

Assignees

Labels

Enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions