urfave v3 commands are very forgiving. how can i make it more strict ? #2191
-
|
urfave v3 allow passing non existing commands. is it possible to make it strict and fail if a command does not exist ? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Well it is assumed that "non existing" commands are the args for the last command that was detected. You could add Arguments for the command to specify that a certain number/type of args needs to be present but beyond that its up to the library user to detect and warn the cli user on non-existing commands. |
Beta Was this translation helpful? Give feedback.
-
|
Thank you so much for your response. I usually don't have commands nested commands i have top level commands like Best Regards |
Beta Was this translation helpful? Give feedback.
-
|
... I thought that this was what the Ah, I wanted to test it out before posting here, but it seems that I usually have a command defined by default. When that is the case, any non-recognised command will automatically use the default. That's actually neat, but it won't help you much if you have a default command, that is — if not, you should be able to catch it with the function that |
Beta Was this translation helpful? Give feedback.
... I thought that this was what the
CommandNotFound:field/function was supposed to do?... I mean, it's the built-in catch-all function for all invalid commands?Ah, I wanted to test it out before posting here, but it seems that I usually have a command defined by default. When that is the case, any non-recognised command will automatically use the default. That's actually neat, but it won't help you much if you have a default command, that is — if not, you should be able to catch it with the function that
CommandNotFoundpoints to.