This library allows command-line tools to encapsulate their usage as a
comment at the top of the main file. Calling
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, ...])
the integer exit code (default zero). RDoc::usage will exit the calling program with this status.
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 © 2004 Dave Thomas. Licensed under the same terms as Ruby
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.