arcanis / clipanion

Type-safe CLI library / framework with no runtime dependencies
https://mael.dev/clipanion/
1.1k stars 61 forks source link

mixedCase params are not recognized when passed as `paramName=value` #145

Open jakub-g opened 1 year ago

jakub-g commented 1 year ago
import { Command, Option } from 'clipanion';

class MixedCaseTest extends Command {
    static paths = [['mixed-case-test']];

    mixedParam = Option.String('--mixedParam');

    async execute() {
        console.log('ok');
    }
}

export default [MixedCaseTest]

Using 3.2.0-rc.14

$ yarn cli mixed-case-test --mixedParam abc
ok

$ yarn cli mixed-case-test --mixedParam=abc
Unknown Syntax Error: Invalid option name ("--mixedParam=abc").

yarn cli mixed-case-test [--mixedParam #0]

If param name is --lower then --lower=value and --lower value both work.

jakub-g commented 1 year ago

The same applies to numbers in the param names

    param = Option.String('--k8s-name');

    async execute() {
        console.log(this.param);
    }

Using --k8s-name abc it prints abc but using --k8s-name=abc it throws.

jakub-g commented 1 year ago

Looks like when using {required:true} then clipanion doesn't like mixedCase at all.

arcanis commented 1 year ago

I think it's a duplicate of #141 - wan't to try PR'ing a fix? 😁