Open ozum opened 3 years ago
// @weareoutman
I'll look at this later. And I also noticed there is a problem when passing --help
or --version
(which are builtin flags) with allowUnknownFlags: true
.
@ozum There is currently a workaround to fix this, set an alias for flags.outDir
, such as:
const flags = { outDir: { type: "string", alias: "o" } };
Or set the alias to "outDir"
or "out-dir"
instead of "o"
if you think which one makes sense.
The related issue is https://github.com/yargs/yargs-parser/issues/359. I suggest to wait for responses of this issue from yargs-parser, before doing fixes in meow.
@weareoutman thanks for the effort and for providing a workaround. It helps a lot.
Only a camel-case key with a kebab-key alias works for me.
const flags = { outDir: { type: "string", alias: "out-dir" } };
Multiple aliases will be supported in the next release, so there will be a workaround with less tradeoffs:
const flags = { outDir: { type: "string", aliases: ["out-dir"], shortFlag: "o" } };
Hi,
Thanks for the library and the great effort.
I need help with an issue:
When I set
allowUnknownFlags
tofalse
, camel-case flags are reported asunknown flag
. However, when I setallowUnknownFlags
totrue
, both camel-cased and dash-cased flags populate the same camel case key (e.g.out-dir
andoutDir
result with{ flags: outDir: "xxx" }
).I expected when
allowUnknownFlags
istrue
, both types of flags are allowed, because dash cased flags are already converted to camel case in the result object.Please see examples below:
allowUnknownFlags: false
with camel-case flagCommand:
$ cmd --outDir models
Result:Unknown flag --outDir
Expected:{ outDir: "models" }
allowUnknownFlags: true
Command:
$ cmd --outDir models
Result:{ outDir: "models" }
Command:
$ cmd --out-dir models
Result:{ outDir: "models" }
Kind Regards,