Open sergei-dyshel opened 1 week ago
I reproduced the problem.
Deep in the code... At the point the error is being thrown, the arguments are in arg.--
instead of argv._
. I can see code "counting" the positionals with and without taking --
into account. I suspect need the first case to include --
length like in the second case.
https://github.com/yargs/yargs/blob/0c95f9c79e1810cf9c8964fbf7d139009412f7e7/lib/command.ts#L511
https://github.com/yargs/yargs/blob/0c95f9c79e1810cf9c8964fbf7d139009412f7e7/lib/validation.ts#L32
(I don't currently understand why halt-at-non-option
triggers the failure.)
I'm trying to write a CLI similar to
ssh
. Here's the minimal example:which just adds one option. When parsing
node my-script.js my-host ls
, I get this error:The only way I manage to get this work is with default command syntax:
though in this case positional arguments are not supported so I can't mix
<host>
with option flags but at least I can extract it as first element ofargs._