Skip to content

Parser: Schematics options camelCase coercion #13544

@nickofthyme

Description

@nickofthyme

🚀 Feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
- [x] schematics

Description

When passing arguments to schematics as options, I would like to be able to pass a dash-case option (i.e. ---dry-run) and get the camelCase equivalent (i.e. dryRun) in the options passed to my schematic.

Currently, if I pass the option option-one as a dash-case argument...

schematics my-collection:my-schematic --option-one=test

The factory function will receive the following options object...

{
    "option-one": "test"
}

Furthermore, if I were to pass both the dash-case and camelCase equivalent of the same argument like so...

schematics my-collection:my-schematic --option-one=test1 --optionOne=test2

The factory function will receive the following options object...

{
    "option-one": "test1",
    "optionOne": "test2"
}

This is not only very confusing but also inconsistent with the base schematics options such as --dry-run. Meaning that the following two commands are analogous...

schematics my-collection:my-schematic --dry-run=true
schematics my-collection:my-schematic --dryRun=true

Thereby treating dry-run as dryRun. I don't see a great use case for allowing two arguments of different cases to coexist.

Describe the solution you'd like

Option 1

Coerce all options argument to camelCase.

Option 2

Smart case corecursion of all options argument based on options schema.

Describe alternatives you've considered

Checking for both dash-case and camelCase options and resolving each option manually based on expected options schema.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions