Skip to content

Add initial#5

Open
duralog wants to merge 3 commits intogkz:masterfrom
duralog:add-initial
Open

Add initial#5
duralog wants to merge 3 commits intogkz:masterfrom
duralog:add-initial

Conversation

@duralog
Copy link
Copy Markdown

@duralog duralog commented Nov 20, 2014

this adds initial values to the parse function.

I additionally added a whole bunch of tests and also nearly committed some tabs too, and realized you didn't have an editorconf

cool lib bro!

@gkz
Copy link
Copy Markdown
Owner

gkz commented Nov 21, 2014

Looks interesting. Can you go over some use cases? How is this better than using default arguments?

@duralog
Copy link
Copy Markdown
Author

duralog commented Nov 21, 2014

I load a config using the rc module, (this allows me to have a separate config for each project, yet one "base" config in the directory below the project that all the configs are derived from.

I can use default for each option, however, if one of the options is't defined in the config it will give an error because undefined is converted to a string.

so, instead of checking undefined for every option, an initial option gave me the results I was looking for.

additionally, I plan to use this parser in a REPL I'm working on, and rebuilding the options array for each command (command's defaults depend on the directory in which you run it), it would make that a lot easier as well

:)

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 this pull request may close these issues.

2 participants