Skip to content

feature request: auto transform option names #5

@teidesu

Description

@teidesu

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
  }
})

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions