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

refactor!: parsing, revisit short option groups, add support for combined short and value #75

Merged
merged 37 commits into from
Mar 12, 2022
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2734d65
Support multiple unit test files
shadowspawn Mar 1, 2022
96f1447
Add isPossibleOptionValue
shadowspawn Mar 2, 2022
9dfd7b6
Add .editorconfig so editor knows about lint settings
shadowspawn Mar 2, 2022
638e07c
Add isLoneShortOption
shadowspawn Mar 2, 2022
c8c9e0c
Add isLongOption
shadowspawn Mar 2, 2022
04d4d95
Add separate dash tests
shadowspawn Mar 2, 2022
512afe5
Update signature for running new tests to arrow functions
shadowspawn Mar 2, 2022
83f0e02
isShortOptionGroup
shadowspawn Mar 2, 2022
686cbe3
Merge branch 'main' into feature/refactor-parse
shadowspawn Mar 2, 2022
bc45095
Update to new calling signature
shadowspawn Mar 3, 2022
0a9c04c
Add findLongOptionForShort
shadowspawn Mar 3, 2022
042d957
Start updating main parsing loop, and rework some utils.
shadowspawn Mar 3, 2022
8f85ecd
Switch loop to shift
shadowspawn Mar 3, 2022
cb93bfa
Add isShortOptionAndValue
shadowspawn Mar 3, 2022
4683053
Form expanded, clearer
shadowspawn Mar 3, 2022
aeff889
Fixes
shadowspawn Mar 3, 2022
0c399bc
Improve comments
shadowspawn Mar 3, 2022
db3e06e
New tests for short option group (and fixes)
shadowspawn Mar 3, 2022
3a7ea3c
Add tests for combining short and value
shadowspawn Mar 4, 2022
bb22e5a
Update package.json
shadowspawn Mar 4, 2022
eac5ecf
Update utils.js
shadowspawn Mar 4, 2022
419060c
Update utils.js
shadowspawn Mar 4, 2022
11bd06f
Add import
shadowspawn Mar 4, 2022
1c1d047
Add exports to keep utils private
shadowspawn Mar 4, 2022
3fcdcb3
AAA: Arrange, Act, Assert
shadowspawn Mar 4, 2022
cf48248
Add tests for failure duck typing
shadowspawn Mar 4, 2022
d2a1bc4
Add another dash example
shadowspawn Mar 4, 2022
22fd538
Make test for undefined more robust
shadowspawn Mar 4, 2022
a409102
Update utils.js
shadowspawn Mar 4, 2022
1bf4cfb
Update utils.js
shadowspawn Mar 5, 2022
228056b
Update utils.js
shadowspawn Mar 5, 2022
bc6dae7
Update package.json
shadowspawn Mar 5, 2022
6153fd2
Update index.js
shadowspawn Mar 5, 2022
eff783e
Comment improvements
shadowspawn Mar 5, 2022
90f9864
Update index.js
shadowspawn Mar 5, 2022
6013dc4
Update test/dash.js
shadowspawn Mar 5, 2022
e4b4f28
Expand test description per feedback
shadowspawn Mar 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update to new calling signature
shadowspawn committed Mar 3, 2022
commit bc45095167549eab1390cfe3f509a372932e39cd
10 changes: 5 additions & 5 deletions test/dash.js
Original file line number Diff line number Diff line change
@@ -11,21 +11,21 @@ const { parseArgs } = require('../index.js');
test("dash: when args include '-' used as positional then result has '-' in positionals", (t) => {
const passedArgs = ['-'];

const args = parseArgs(passedArgs);
const result = parseArgs({ args: passedArgs });
const expected = { flags: {}, values: {}, positionals: ['-'] };
t.deepEqual(args, expected);
t.deepEqual(result, expected);

t.end();
});

// If '-' is a valid positional, it is symmetrical to allow it as an option value too.
test("dash: when args include '-' used as space-separated option value then result has '-' in option value", (t) => {
const passedArgs = ['-v', '-'];
const options = { withValue: ['v'] };
const options = { v: { type: 'string' } };

const args = parseArgs(passedArgs, options);
const result = parseArgs({ args: passedArgs, options });
const expected = { flags: { v: true }, values: { v: '-' }, positionals: [] };
t.deepEqual(args, expected);
t.deepEqual(result, expected);

t.end();
});