Sha256: 3c5d06c88339e71c947a5ad83b0ee8ba44d4849523d7314d3bd3e76026a77dad
Contents?: true
Size: 1.87 KB
Versions: 2
Compression:
Stored size: 1.87 KB
Contents
# Quickl example: hello This example shows how to create a really simple commandline program. ## Structure The structure it follows is simply: # # Short description here # # SYNOPSIS # Usage: ... # # OPTIONS # #{sumarized_options} # # DESCRIPTION # Long description here... # class SimpleCommand < Quickl::Command(__FILE__, __LINE__) # install options below options do |opt| # _opt_ is an OptionParser instance end # install the code to run the command def execute(args) # _args_ are non-option command line parameters end end # To run the command, typically in a bin/simple_command # shell file SimpleCommand.run(ARGV) ## Example Try the following: ./hello # => Hello world! ./hello --capitalize # => Hello World! ./hello bob # => Hello bob! ./hello --capitalize bob # => Hello Bob! ./hello --version # => hello 0.1.0 (c) 2010, Bernard Lambeau ./hello --help # => ... ./hello too many arguments # => needless argument: too many arguments # => hello [--help] [--version] [--capitalize] [WHO] ./hello --no-such-option # invalid option: --no-such-option # hello [--help] [--version] [--capitalize] [WHO] ## You have to known that ... * An **instance** of command is actually executed. Therefore, it is safe to install instance variables through options and to use them in execute(). * Documentation shown with --help is the rdoc documentation evaluated in the binding of the SimpleCommand **class**. Therefore, you can use #{...} to display specific things (like #{sumarized_options}). * Default error handlers are installed by default to catch Interrupt, Quickl::Exit and OptionParser::Error. See error_handling example to learn more about them.
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
quickl-0.2.0 | examples/hello/README.md |
quickl-0.1.1 | examples/hello/README.md |