An open API service indexing awesome lists of open source software.

https://github.com/rubyworks/cli_base

Killer Commandlines
https://github.com/rubyworks/cli_base

Last synced: 4 months ago
JSON representation

Killer Commandlines

Awesome Lists containing this project

README

          

= CLI::Base

{Website}[http://rubyworks.github.com/cli_base] |
{Source Code}[http://github.com/rubyworrks/cli_base] |
{Report Issue}[http://github.com/rubyworrks/cli_base/features] |
{#rubyworks}[irc://irc.freenode.org/rubyworks]

{}[http://travis-ci.org/rubyworks/cli_base]

== DESCRIPTION

CLI::Base is a very striaght-forward CLI framework for Ruby. CLI::Base is
a *COM* Command-to-Object Mapping library. A command line tool can be defined
using nothing more than Ruby's own standard syntax. No special DSL is required.

IMPORTANT! CLI::Base's help feature is Ruby 1.9+ only. It does NOT support
1.8.7 or older.

== SYNOPSIS

Using CLI::Base is straight-forward. Simply subclass the `CLI::Base` base
class and add methods to handle command-line options. Writer methods
(those ending in '=') coorepsond to an option and a query method (ending in '?')
marks an option a flag. For example, here is a simple commandline tool to run
a Ruby script.

require 'cli/base'

class RunCLI < CLI::Base
# Require LIBRARY before executing your script.
def require=(lib)
require lib
end
alias :r= :require=

# Include PATH in $LOAD_PATH.
def include=(path)
$:.unshift path
end
alias :I= :incude

# Run in DEBUG mode.
def debug?
$DEBUG = true
end

# Show this message.
def help?
puts self
exit
end
alias :h? :help?

# Run the command.
def main(script)
load(script)
end
end

For a more detail example see EXAMPLE.md.

== COPYRIGHTS

Copyright (c) 2009 Rubyworks.

This program is distributed under the terms of the **BSD-2-Clause** license.

Please see COPYING.rdoc file for details.