rdoc.usage 

Joined:
12/20/2011
Posts:
1

January 06, 2012 07:32:25    Last update: January 06, 2012 07:32:25
rdoc documentation:
usage(*args)

Display usage information from the comment at the top of the file. String arguments identify specific sections of the comment to display. An optional integer first argument specifies the exit status (defaults to 0)


put something like this on top of your script:
# == Synopsis 
#   Blah blah blah.
#
# == Examples
#   This command does blah blah blah.
#     sample command exec
#
# == Usage 
#   <file> [options] args
#
# == Options
#   -h, --help          Displays help message
#
# == Author
#   YourName
#
# == Copyright
#   Copyright (c) 


method to display it
    def output_usage
      RDoc::usage('usage') # gets usage from comments above
    end


bind it to the '-h' option via optionparser
opts.on('-h', '--help')       { output_help }


source
http://blog.toddwerth.com/entries/5
Share |
| Comment  | Tags