davetron5000 / optparse-plus

Start your command line scripts off right in Ruby
http://davetron5000.github.com/optparse-plus
Apache License 2.0
521 stars 54 forks source link

Possible to print out help again during validation? #89

Closed rchady closed 9 years ago

rchady commented 9 years ago

When using OptionParser, it is possible to output the full help after a custom message. I uses this when validating the arguments to my commands. Is it possible to do this using Methadone? For example, I am writing a command that processes ARGF, but if they do not provide something on STDIN, I want to be able to give them an error message that they need to provide some input and then re-print the normal output of command -h.

davetron5000 commented 9 years ago

help_now! should do this. It raises an exception that Methadone interprets as an erroneous exit that will trigger the help, e.g.

help_now!("provide data on stdin or as a list of files") if ARGF.empty?

Let me know if that's not what you're looking for.

davetron5000 commented 9 years ago

Re-open if my solution didn't work for you.