Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handler for command line parameters and option errors #105

Open
eguzki opened this issue Jul 10, 2019 · 0 comments
Open

Handler for command line parameters and option errors #105

eguzki opened this issue Jul 10, 2019 · 0 comments

Comments

@eguzki
Copy link

eguzki commented Jul 10, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants