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

Feature Request: Yargs parser configuration #326

Closed
arbue opened this issue Oct 15, 2021 · 2 comments · Fixed by #334
Closed

Feature Request: Yargs parser configuration #326

arbue opened this issue Oct 15, 2021 · 2 comments · Fixed by #334
Assignees
Labels
feature New feature or request released

Comments

@arbue
Copy link

arbue commented Oct 15, 2021

The yargs package allows to configure the args parser to change the default behavior. https://github.com/yargs/yargs/blob/main/docs/advanced.md#customizing

It would be good if we could also pass the configuration via the ProgramOptions to yargs.

I have a concrete case for this in our project. We have options which are in camelCase e.g."--helloWorld". The yargs parser in the default configuration adds an alias "hello-world" to the args object:

{
"helloWorld": "Greetings",
'hello-world': "Greetings"
}

This can be avoided with the yargs parser config 'strip-dashed': true

For now I have patched the createYargsInstance() method like:

    createYargsInstance() {
         // omitted
        yargs.parserConfiguration({
            'strip-dashed':true
        });
        // Non-configurable options
          // omitted
    }

Apparently this breaks the autocompletion function. Maybe there is a better way...

But I think this feature is also useful to others as well. So long story short maybe the ProgramOptions can be extended with the yargs parser config options and pass it to the yargs parser.

@hongaar hongaar self-assigned this Oct 25, 2021
@hongaar hongaar added the feature New feature or request label Oct 25, 2021
@hongaar
Copy link
Owner

hongaar commented Oct 25, 2021

🎉 This issue has been resolved in version 1.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@hongaar
Copy link
Owner

hongaar commented Oct 25, 2021

@arbue thanks for suggesting this, it should be possible to do this with the latest release. Let me know if you encounter problems with the implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants