Closed antongolub closed 2 years ago
@sindresorhus, what do you think of that?
I would recommend trying to find a way to solve this without introducing a new flag. Maybe open an issue on https://github.com/yargs/yargs-parser (the parser meow
uses) with your problem statement.
There's no need for yargs-* patching. I just thought a flag would be a bit more convenient than:
const cli = meow({
importMeta: import.meta,
description: 'Custom description',
help: `
Usage
foo <input>
`,
// preferNestedFlags: true,
flags: {
foo: {
type: 'string',
},
},
get argv() {
const argvStart = process.argv.includes('--') ? process.argv.indexOf('--') + 1 : 2
return process.argv.slice(argvStart)
}
});
If a flag actually makes sense for this, it makes more sense to add it to the actual argument parser.
-- --foo='bar'
is more of an aesthetic wish. npx -p pkg1 -p pkg2 some-cli --foo='bar'
works fineget argv() { const argvStart = process.argv.includes('--') ? process.argv.indexOf('--') + 1 : 2 return process.argv.slice(argvStart) }
completely covers my issue
Real-world issue: I got stuck in a corner case when I couldn't parametrize CLI inside another CLI:
I suggest introducing
preferNestedFlags
option to workaround the limitation: