You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed some differences in how Cliffy handles the -- argument compared to most other command line tools (that I'm aware of):
According to POSIX, the -- argument indicates that all subsequent arguments should be treated not as options, but as positional arguments. For example, when grep-ing a file for -v, you have to use grep -- -v file to tell grep to treat -v as an argument instead of an option.
In Cliffy, this seems to be impossible, at least for required arguments (or at least I can't figure out how to do it).
For optional arguments, it would be possible to fill unset arguments with the elements of the `literal' array:
awaitnewCommand().name("my-command").arguments("[things...:string]").action(function(options, ...things){constliteral=this.getLiteralArgs();things=[...things, ...literal];console.log({ options, things });}).parse(Deno.args);
Now we can run my-command -- --foo --bar and we get { options: {}, things: [ "--foo", "--bar" ] } in return.
But if we change arguments("[things...:string]") to arguments("<things...:string>") (make it a required argument), this is no longer possible:
error: Missing argument(s): things
(although my-command foo -- --bar would work since foo is the required argument and --bar is merged in)
Did I just miss something or is this really not possible?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I've noticed some differences in how Cliffy handles the
--argument compared to most other command line tools (that I'm aware of):According to POSIX, the
--argument indicates that all subsequent arguments should be treated not as options, but as positional arguments. For example, whengrep-ing a file for-v, you have to usegrep -- -v fileto tellgrepto treat-vas an argument instead of an option.In Cliffy, this seems to be impossible, at least for required arguments (or at least I can't figure out how to do it).
For optional arguments, it would be possible to fill unset arguments with the elements of the `literal' array:
Now we can run
my-command -- --foo --barand we get{ options: {}, things: [ "--foo", "--bar" ] }in return.But if we change
arguments("[things...:string]")toarguments("<things...:string>")(make it a required argument), this is no longer possible:(although
my-command foo -- --barwould work sincefoois the required argument and--baris merged in)Did I just miss something or is this really not possible?
Beta Was this translation helpful? Give feedback.
All reactions