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

v2.3.x Do Not Handle Commandline Arguments #30

Closed
KSR-Yasuda opened this issue Jun 4, 2020 · 3 comments · May be fixed by #31
Closed

v2.3.x Do Not Handle Commandline Arguments #30

KSR-Yasuda opened this issue Jun 4, 2020 · 3 comments · May be fixed by #31

Comments

@KSR-Yasuda
Copy link

Since v2.3.0, it looks ignoring commandline arguments.

% node -v
v12.18.0
% npm -v
6.14.5
% sudo npm -g update
/usr/local/bin/password-generator -> /usr/local/lib/node_modules/password-generator/bin/password-generator
+ [email protected]
removed 3 packages and updated 1 package in 0.533s
% password-generator -h
gavufivoni
% sudo npm -g i [email protected]
/usr/local/bin/password-generator -> /usr/local/lib/node_modules/password-generator/bin/password-generator
+ [email protected]
updated 1 package in 0.278s
% password-generator -h
xuwenazejo

The latest valid ver. is v2.2.3:

% sudo npm -g i [email protected]
/usr/local/bin/password-generator -> /usr/local/lib/node_modules/password-generator/bin/password-generator
+ [email protected]
added 3 packages from 2 contributors and updated 1 package in 0.935s
% password-generator -h
Generates a memorable password

Options:
  -l: Password length                      [default: null]
  -c: Generates a non memorable password   [default: "memorable"]
  -p: Pattern to match for the generated password
  -h: Displays this help
@KSR-Yasuda
Copy link
Author

  if (arg[0] === '-') {
    var equalIdx = arg.indexOf('=');
    if (equalIdx === -1) {
      memo[arg[1]] = nextArg && nextArg[0] === '-' ? true : nextArg;
    }

It looks setting undefined for password-generator -h.
The option -h has no nextArg, and it sets missing nextArg or undefined.

@bermi
Copy link
Owner

bermi commented Jun 4, 2020

@KSR-Yasuda looks like all it might be needed to fix this issue is to default nextArg to true

-  var nextArg = rawArgs[idx + 1];
+  var nextArg = rawArgs[idx + 1] || true;

What other case is handled by the regexp on #31 will not be taken into account by the simple fix above?

@bermi bermi closed this as completed in fe1e8cb Jun 4, 2020
@KSR-Yasuda
Copy link
Author

Yes, but it converts empty string to true (I mean, the case rawArgs[idx + 1] is "").

The current available options don't want empty string for any cases, though,
I wondered whether it is correct.

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 a pull request may close this issue.

2 participants