-
Notifications
You must be signed in to change notification settings - Fork 2
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
few ideas #3
base: main
Are you sure you want to change the base?
few ideas #3
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,10 @@ npm install minargs | |
- `recursive` (`Boolean`) | ||
- Default: `false` | ||
- Define whether or not to end parsing when a bare `--` marker is found | ||
🤔 Is `recursive` really essential? it seems to me that it can be fairly | ||
trivial for the user to be recursively parsing the remainder in case they need | ||
it, IMO having in mind a lib that strives to be minimal, this part can be | ||
removed for the sake of simplicity. | ||
|
||
### Returned Values | ||
|
||
|
@@ -96,6 +100,13 @@ positionals // ["-"] | |
remainder // ["--baz"] | ||
argv // [ { index: 0, type: 'argument', value: { name: "foo", value: "bar" } } ... ] | ||
``` | ||
🤔 I'm confused with the returned value of this example here since it seems to | ||
conflict a bit with the statement above: | ||
|
||
> The `type` `"value"` will only ever be defined -- in place of `"positional"` -- when `positionalValues=true` | ||
|
||
What "type value" is this referring to? is it `argv`'s `value` property? Or | ||
maybe it's a top level property that will replace `positional`? | ||
Comment on lines
+103
to
+109
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I think this example needs to be updated. The first parsed element is a positional |
||
|
||
#### Handling existence | ||
|
||
|
@@ -332,6 +343,7 @@ if (args.help) { | |
#### Is `--foo` the same as `--foo=true`? | ||
* No. | ||
* `--foo` will parse to `{ args: { "foo": [""] } }` & `--foo=true` to ` { args: { "foo": ["true"] } }` respectively | ||
🙏 | ||
Comment on lines
345
to
+346
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope this emoji means this is a good thing? Not coercing/inferring types is a big part of this approach. |
||
|
||
#### Are environment variables supported? | ||
* No. | ||
|
@@ -364,6 +376,7 @@ if (args.help) { | |
* No. | ||
* `minargs` aligns with the [POSIX Argument Syntax](https://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html) here (ie. "Arguments are options if they begin with a hyphen delimiter") | ||
* `--number -2` will be parsed as `{ args: { "number": [""], "2": [""] } }` | ||
👍 | ||
Comment on lines
378
to
+379
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed - unquoted values shouldn't be parsed as values if they start with |
||
* You will have to use explicit value setting to make this association (ex. `--number=-2`) & may further require validation/type coercion to determine if the value is a `Number` (as is shown in the usage examples above) | ||
|
||
### CLI | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally had this removed as you're right that it is trivial to add (although it's definitely nice to have baked in & is consistent with what we've done for functions like
mkdir
/rmdir
)