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

few ideas #3

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Comment on lines +46 to 50
Copy link
Owner

@darcyclarke darcyclarke May 23, 2022

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)

### Returned Values

Expand Down Expand Up @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The 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 - without a value (and that's not shown here). I'll update this.


#### Handling existence

Expand Down Expand Up @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The 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.
Expand Down Expand Up @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The 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 -. It's pretty straightforward.

* 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
Expand Down