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

Trailing and leading quotes #222

Closed
wants to merge 2 commits into from

Conversation

juergba
Copy link
Contributor

@juergba juergba commented Nov 17, 2019

Description

closes #201

Currently trailing and leading quotes are removed, this applies to string and also to string[] input.

> require('yargs-parser')([ '--arg', '"option"' ])
{ _: [], arg: 'option' }

One (main?) reason for this: --arg "--option"
if user needs --option to be handled as value (no option), he wraps the value into quotes which are removed by yargs-parser later on ==> { _: [], arg: '--option' }
Problem: each and every tl-quotes are removed.

Description of change

This is a delicate topic, so the following is a proposition.

  • we distinguish between string input and string[] input.
    • string: there are good reasons to remove tl-quotes, as does eg Bash.
    • string[]: we never remove any tl-quotes.
  • therefore we move the quote handling from "index.js" to "tokenize-arg-string.js".
  • we introduce the escaped dash '\\-':
    [ '--arg', '\\--option' ] ==> { _: [], arg: '--option' }

BREAKING CHANGE

@juergba juergba changed the title Issue/removing quotes Trailing and leading quotes Nov 17, 2019
args.foo.should.equal('-hello world')
args.bar.should.equal('--goodnight moon')
const args2 = parser(['--foo', '\\-hello world', '--bar=--goodnight moon'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love the \\ syntax, is there prior art this is based on?

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.

Trailing and leading quote characters are removed
2 participants