cri
cri copied to clipboard
Handler for command line parameters and option errors
There are some parameter and option validations that the library catches and leaves no option to the library client. By default, SystemExit
exception is raised. Some of those errors would be Cri::Parser::IllegalOptionError
, Cri::ArgumentList::ArgumentCountMismatchError
. But there are others as well.
To illustrate, a simple use case: when the user does not provide positional parameter:
param :filename
run do |opts, args, cmd|
puts "Reading #{args[:filename]}"
end
% ./mycommand
mycommand: incorrect number of arguments given: expected 1, but got 0
The message is clear, but mycommand
would like to print help message for instance.
The issue is not a big deal, but still nice to have.
Any way to have this behavior I could miss?