Sha256: 29a5a5042327252c5d79caaa2e53eb6b19d11c94d371ef389c419746339fc9fc

Contents?: true

Size: 904 Bytes

Versions: 1

Compression:

Stored size: 904 Bytes

Contents

# CLI

A CLI app framework

## Setup

    gem install wojtekmach-cli

## Example


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

```ruby
#!/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 `cli` binary like that:

```ruby
#!/usr/bin/env 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

1 entries across 1 versions & 1 rubygems

Version Path
wojtekmach-cli-0.3.0 README.md