Skip to content
General Thor extension with nice, coloured console UI
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
bin
lib
test
.document
.gitignore
LICENSE
README.rdoc
Rakefile
VERSION
thor-cheese.gemspec

README.rdoc

Cheese

A simple Thor-based Mixin and console-application skeleton. The structure was inspired by Bundler. Cheese provides a colourful UI Shell.

Installation

gem install thor-cheese

Usage

$ thor-cheese

Follow the menu

It's very simple to create a Cheese-based console application. First create an executable in your Gem's /bin directory:

#!/usr/local/bin/ruby

$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')

require 'cheese' require 'your-app' require 'your-app/cli'

begin YourApp::CLI.start rescue YourApp::Error => e YourApp.ui.error e.message exit e.status_code end

Next, in your Gem's base Module, eg: lib/your-app.rb, include the Cheese mixin and implement your Cheese::Error extensions. module YourApp VERSION = “0.1.0”

## # include the Cheese module into your base nameespace. This allows you to boot an # instance of the colourful Cheese::UI::Sheel # include Thor::Cheese

# Do your autoloads here. autoload :MightyGenerator, 'your-app/mighty-generator' ## # Example error-extension # class Error < Thor::Cheese::Error; status_code(666) ; end

end

Finally, place your Thor extension in your Gem's base-package, eg: lib/your-app/cli.rb. Override the constructor and send the shell into the class-method shell mixed-in with include Cheese in the previous step.

## # Example Thor instance # module YourApp class CLI < Thor

desc “say”, “Say cheese and receive” def say(word) if word == 'cheese' YourApp.ui.confirm(“CHEESE!”) else YourApp.ui.warn(“ '#{word}'?? No cheese for you :(”) end end

## # For your convenience, override initialize and boot an instance of XCLI::UI::Shell by sending your # shell method mixed-in by Cheese. # YourApp.ui.confirm(“That was good cheese”) # YourApp.ui.warn(“That's stinky cheese”) # YourApp.ui.error(“That was horrible cheese”) # def initialize(*) YourApp.shell = shell super end end end

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 © 2010 Christocracy. See LICENSE for details.

Something went wrong with that request. Please try again.