https://github.com/rubyworks/cli_base
Killer Commandlines
https://github.com/rubyworks/cli_base
Last synced: 4 months ago
JSON representation
Killer Commandlines
- Host: GitHub
- URL: https://github.com/rubyworks/cli_base
- Owner: rubyworks
- License: other
- Created: 2010-09-30T02:29:26.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2011-11-11T14:51:56.000Z (over 14 years ago)
- Last Synced: 2025-04-02T09:45:14.252Z (11 months ago)
- Language: Ruby
- Homepage: http://rubyworks.github.com/cli_base
- Size: 1.32 MB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
- Changelog: HISTORY.rdoc
- License: COPYING.rdoc
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.