drydock / 0.5.1
| Short description: | A DSL for seaworthy command line apps | |||||||
|---|---|---|---|---|---|---|---|---|
| Category: | Library/Development | |||||||
| Status: | beta | |||||||
| Created: | 2009-03-31 19:40:56 GMT | |||||||
| Last update: | 2009-03-31 19:40:56 GMT | |||||||
| Owner: | delano (Projects of this owner) | |||||||
| Homepage: | http://github.com/delano/drydock | |||||||
| Download: | http://github.com/delano/drydock/tarball/drydock-0.5.1 | |||||||
| License: | BSD-type | |||||||
| Dependency: |
|
|||||||
| Description: | Drydock - v0.5Inspired by github-gem and bmizerany-frylock. OverviewDrydock is a seaworthy DSL for command line apps. It’s contained in a single .rb file so it’s easy to copy directly into your project. InstallOne of:
Or for GitHub fans:
ExamplesSee bin/example for more.
require 'drydock'
default :welcome
before do
# You can execute a block before the requests command is executed. Instance
# variables defined here will be available to all commands.
end
desc "A friendly welcome to the Drydock"
command :welcome do
puts "Welcome to Drydock."
puts "For available commands:"
puts "#{$0} show-commands"
end
usage "USAGE: #{$0} laugh [-f]"
desc "The captain commands his crew to laugh"
option :f, :faster, "A boolean value. Go even faster!"
command :laugh do |obj|
# +obj+ is an instance of Drydock::Command. The options you define are available
# via obj.option.name
answer = !obj.option.faster ? "Sort of" : "Yes! I'm literally laughing as fast as possible."
puts "Captain Stubing: Are you laughing?"
puts "Dr. Bricker: " << answer
end
class JohnWestSmokedOysters < Drydock::Command
# You can write your own command classes by inheriting from Drydock::Command
# and referencing it in the command definition.
def ahoy!; p "matey"; end
end
desc "Do something with John West's Smoked Oysters"
command :oysters => JohnWestSmokedOysters do |obj|
p obj # => #<JohnWestSmokedOysters:0x42179c ... >
end
desc "My way of saying hello!"
command :ahoy! => JohnWestSmokedOysters
# If you don't provide a block, Drydock will call JohnWestSmokedOysters#ahoy!
More InformationCredits
LicenseSee LICENSE.txt |
|||||||
| Versions: | [0.6.5 (2009-06-04)] [0.6.0 (2009-04-30)] [0.5.4 (2009-04-18)] [0.5.1 (2009-03-31)] | |||||||