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: auto transform option names #5

Open
teidesu opened this issue Oct 30, 2024 · 0 comments
Open

feature request: auto transform option names #5

teidesu opened this issue Oct 30, 2024 · 0 comments
Assignees

Comments

@teidesu
Copy link

teidesu commented Oct 30, 2024

currently if i use camel-cased arguments in options, brocli would keep it as-is:

const foo = command({
  name: 'foo',
  options: {
    fooBar: string()
  },
  handler: console.log
})

would result in something along

$ node test.js foo -h

Usage:
  foo [flags]

Flags:
      --fooBar string

$ node test.js foo --foo-bar 123
Unrecognized options for command 'foo': --foo-bar

and while that's mostly personal preference, i think that camel-cased arguments are ugly and prefer them being in kebab-case. and currently the only way to achieve that is manually putting kebab-cased version everywhere (either as a key or a display name)

i propose some way for library users to achieve that more cleanly, probably by exposing some kind of delegate in the run() config, something like

run([...], {
  transformName: {
    fromCli: kebabToCamel,
    toCli: camelToKebab
  }
})
@Sukairo-02 Sukairo-02 self-assigned this Nov 3, 2024
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

No branches or pull requests

2 participants