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

Short option property does not update when using long option #150

Open
1 of 3 tasks
shanoaice opened this issue Jan 6, 2023 · 2 comments · May be fixed by #153
Open
1 of 3 tasks

Short option property does not update when using long option #150

shanoaice opened this issue Jan 6, 2023 · 2 comments · May be fixed by #153

Comments

@shanoaice
Copy link

Issue Type

  • Bug Report
  • Feature Request
  • Other

Expected

I got such code:

cli.option('-b, --base-url <baseUrl>', 'Set the instance URL', {
	default: 'https://github.com',
})

const opt = cli.parse()

console.log(opt)

When I run with --base-url "https://gitlab.com", I expect it to output such object:

{
  args: [],
  options: { '--': [], b: 'https://gitlab.com', baseUrl: 'https://gitlab.com' }
}

Actual

Instead it gives me this:

{
  args: [],
  options: { '--': [], b: 'https://github.com', baseUrl: 'https://gitlab.com' }
}

Info

@Rendez
Copy link

Rendez commented Mar 1, 2023

This seems controversial at first, but I think he's right. They are two different flags, but the same option in the end and they should be getting the same default or value. I will take this on and see how far I can get.

@Rendez
Copy link

Rendez commented Mar 2, 2023

The MR above fixes the issue when setting default. However, I left intact the part where the underlying mri library, used for option parsing, doesn't parse -b if you only pass the --base-url option, but parses both if -b is passed. I hope this addresses the main problem which was in my opinion, setting the default to one of the names when the second (long version) is provided.

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 a pull request may close this issue.

2 participants