Sha256: e53344d573a507f2c42f365f30f2ccff9ed58c77fb16394f5f6136c5a6585919

Contents?: true

Size: 974 Bytes

Versions: 2

Compression:

Stored size: 974 Bytes

Contents

# CLI

A CLI app framework

## Setup

    gem install wojtekmach-cli

## 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!

Alternatively, you can use the `rb-cli` binary like that:

    #!/usr/bin/env rb-cli

    name "hello"
    version "0.0.1"

    default do
      ...
    end

And run it:

    % ./hello.rb

## Licence

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wojtekmach-cli-0.2.0 README.md
wojtekmach-cli-0.1.3 README.md