Skip to content

Poor error messages, poor extensibility #19

@rkeene

Description

@rkeene

Currently this library does not have good error messages by default. For example, the example program:

const getopt = require('node-getopt');
const info = getopt.create([
	['t', 'test=ARG', 'Test']
]).bindHelp().parseSystem();

This has a few problems that result in poor error messages:

  • Using it as ./example.js --test results in: option test need argument ; The argument I used is "--test" not "test", this is what should be reported to the user. This is what GNU "ls" returns: ls: option '--format' requires an argument
  • Using it as ./example -t results in: option test need argument ; The argument I used is "-t" not "test" (or even "--test"), this is what should be reported to the user. This is what GNU "ls" returns: ls: option requires an argument -- 'I'

Further, there is no capability to fix this without modifying the library because the error() method is passed in an Error object with a string as its error, which does not contain enough information to determine what the error should actually be. This is poor extensibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions