Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poor error messages, poor extensibility #19

Open
rkeene opened this issue Apr 10, 2021 · 0 comments
Open

Poor error messages, poor extensibility #19

rkeene opened this issue Apr 10, 2021 · 0 comments

Comments

@rkeene
Copy link

rkeene commented Apr 10, 2021

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.

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

No branches or pull requests

1 participant