| Path: | rdoc/usage.rb |
| Last Update: | Sun Jun 01 17:54:32 -0500 2008 |
This library allows command-line tools to encapsulate their usage as a comment at the top of the main file. Calling RDoc::usage then displays some or all of that comment, and optionally exits the program with an exit status. We always look for the comment in the main program file, so it is safe to call this method from anywhere in the executing program.
RDoc::usage( [ exit_status ], [ section, ...]) RDoc::usage_no_exit( [ section, ...])
where:
| exit_status: | the integer exit code (default zero). RDoc::usage will exit the calling program with this status. |
| section: | an optional list of section names. If specified, only the sections with the given names as headings will be output. For example, this section is named ‘Usage’, and the next section is named ‘Examples’. The section names are case insensitive. |
# Comment block describing usage
# with (optional) section headings
# . . .
require 'rdoc/usage'
# Display all usage and exit with a status of 0
RDoc::usage
# Display all usage and exit with a status of 99
RDoc::usage(99)
# Display usage in the 'Summary' section only, then
# exit with a status of 99
RDoc::usage(99, 'Summary')
# Display information in the Author and Copyright
# sections, then exit 0.
RDoc::usage('Author', 'Copyright')
# Display information in the Author and Copyright
# sections, but don't exit
RDoc::usage_no_exit('Author', 'Copyright')
Dave Thomas, The Pragmatic Programmers, LLC
Copyright (c) 2004 Dave Thomas. Licensed under the same terms as Ruby
ruby-doc.org is hosted and maintained by James Britt and Happy Camper Studios, a Ruby application development company in Phoenix, Arizona. The site was created in 2002 as part of the Ruby Documentation Project to promote the Ruby language and to help other Ruby hackers.
Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.
For more information on the Ruby programming language, visit ruby-lang.org.
Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.