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

[readme]: document string positionals #53

Merged
2 commits merged into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ Return an argument object `argv` populated with the array arguments from `args`.
them.

Numeric-looking arguments will be returned as numbers unless `opts.string` or
`opts.boolean` is set for that argument name.
`opts.boolean` contains that argument name. To disable numeric conversion
for non-option arguments, add `'_'` to `opts.string`.

Any arguments after `'--'` will not be parsed and will end up in `argv._`.

Expand Down
6 changes: 4 additions & 2 deletions test/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,14 @@ test('strings', function (t) {
});

test('stringArgs', function (t) {
var s = parse([' ', ' '], { string: '_' })._;
t.same(s.length, 2);
var s = parse([' ', ' ', '3'], { string: '_' })._;
t.same(s.length, 3);
t.same(typeof s[0], 'string');
t.same(s[0], ' ');
t.same(typeof s[1], 'string');
t.same(s[1], ' ');
t.same(typeof s[2], 'string');
t.same(s[2], '3');
t.end();
});

Expand Down