Sha256: 41de4c54967ec24a4987942d64aee81bd610f6501cd0500e4df296e039305c93

Contents?: true

Size: 807 Bytes

Versions: 1

Compression:

Stored size: 807 Bytes

Contents

# CLI

A CLI app framework

## Setup

    git clone /path/to/cli.git
    cd cli
    rake install

## Example

Let's say you have a file `hello.rb`:

    #!/usr/bin/env ruby
    require "rubygems"
    require "cli"

    CLI.app do
      name    "hello"
      version "0.0.1"

      option "-m", "--message MSG" do |msg|
        options[:msg] = msg
      end

      action "hi" do
        puts "Hi, World!"
      end

      default do
        str = options[:msg] || "Hello"
        puts "#{str}, World!"
      end
    end

You can now use it like this:

    ruby hello.rb        # => Hello, World!
    ruby hello.rb hi     # => Hi, World!
    ruby hello.rb -m Bye # => Bye, World!

## Licence

CLI is Copyright (c) 2011 Wojciech Mach and distributed under the MIT license. See the LICENCE file for more info.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wojtekmach-cli-0.1.0 README.md