Sha256: 54873d3496d0d0b446169cb6914ffc964c999d349c526e06d34facbb844d570e

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

# Martin

An ode to the Rat Pack (Dean Martin) with a Sinatra style DSL for creating command line interfaces to your applications

## Example

### `calc.rb`

    class Calculator
        def add(*nums)
            nums.reduce(:+)
        end
    end

### `app.rb`

    require File.dirname(__FILE__) + '/calc'
    require 'martin'

    configure do
        @calc = Calculator.new
    end

    command /add (\d+) to (\d+)/ do |a, b|
        puts @calc.add(a.to_i, b.to_i)
    end

    error do |input|
        puts 'Error: command ' + input.split.first + ' not found.'
    end
  
And that's it! Now run `ruby app add 15 to 25` and the application 
should return `40`

This works great coupled with [highline][1]  
[Rubular][2] is a great place to test your regular expressions

## Note on Patches/Pull Requests
 
* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
  future version unintentionally.
* Commit, do not mess with rakefile, version, or history.
  (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.

## Copyright

Copyright (c) 2010 Ryan Lewis. See LICENSE for details.


  [1]: http://github.com/JEG2/highline "highline"
  [2]: http://rubular.com/ "rubular"

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
martin-0.1.3 README.md
martin-0.1.2 README.md