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
Of course, it works if I change it to $b. This one took a long time to debug 😄
If they should take atoms, I think short should only take one letter atoms and error out otherwise, and long should take any string atom and automatically prepend it with "-" so that the default flag format is --flag (since most UNIX CLIs follow that).
The text was updated successfully, but these errors were encountered:
I dug into this specific issue and found that argparse already throws when short is not a printable character, or long is not a printable string.
Now what's been happening with cli, it was catching this exception, and printing this to Erlang Logger:
This is a deliberate decision, to keep running cli even when some command has invalid description, and just log instead. The reason is, we often have dozens and even hundreds of modules exporting cli, and it happens that some commands may have a broken description, or something else broken. Therefore we cannot fail the entire cli, and have to ignore the malformed command.
I understand that this behaviour is not exactly useful for smaller projects. What I think of, there is warn option available for cli:run/2, that can be set to warn (default meaning "print the discovered issue to logger") and suppress (silently ignore). I can add another value, halt, that would mean "print the problem to stdout and halt the VM".
Another clue is given by Dialyzer, it immediately warns against atoms set as short or long attributes. It might be enough signal to figure out the invalid argument description.
It would be nice if the
short
andlong
options for arguments could take atoms, or at least throw errors if they won't. I had this configuration:Calling the escript CLI gave this output:
Of course, it works if I change it to
$b
. This one took a long time to debug 😄If they should take atoms, I think
short
should only take one letter atoms and error out otherwise, andlong
should take any string atom and automatically prepend it with"-"
so that the default flag format is--flag
(since most UNIX CLIs follow that).The text was updated successfully, but these errors were encountered: