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

allow yargs.parse() and yargs(foo).argv to accept a raw argument string #331

Merged
merged 3 commits into from
Jan 9, 2016

Conversation

bcoe
Copy link
Member

@bcoe bcoe commented Jan 3, 2016

@kellyselden made the great suggestion that yargs be able to handle a raw argument string, prior to it being parsed by the OS. Like so:

var a1 = yargs.parse('-x=\'marks "the" spot\' --foo "break \'dance\'"')

One great advantage to this is that it makes yargs easier to embed in unorthodox environments, .e.g., a REPL in the web-browser.

fixes #327

@kellyselden
Copy link
Contributor

After looking at your tests, it looks like this will work quite well. Nice quick work!

bcoe added a commit that referenced this pull request Jan 9, 2016
allow yargs.parse() and yargs(foo).argv to accept a raw argument string
@bcoe bcoe merged commit 6b9890d into master Jan 9, 2016
@nexdrew
Copy link
Member

nexdrew commented Jan 9, 2016

@bcoe Sorry about this, I started to take a look a couple different times and never finished my review.

For some reason I thought the tests already used a string of args, so thought we could reuse logic there, but that's not the case - they use an array of strings.

So overall this LGTM. Nice work!

@bcoe
Copy link
Member Author

bcoe commented Jan 9, 2016

@nexdrew I was thinking that we could actually update the tests to use a string instead, why don't I do that good use of this new feature.

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.

Allow args string in .parse()
3 participants