Release Name: 0.4.0
Notes:
= Drydock - v0.4
Inspired by github-gem and bmizerany-frylock.
== Overview
Drydock is a seaworthy DSL for command line apps. It is contained in a single .rb which can be copied directly into your project.
== Install
One of:
* gem install drydock
* copy lib/drydock.rb into your lib directory.
Or for GitHub fans:
* git clone git://github.com/delano/drydock.git
* gem install delano-drydock
== Examples
See 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 Information
* GitHub[http://github.com/delano/drydock]
* RDocs[http://drydock.rubyforge.org/]
* Inspiration[http://www.youtube.com/watch?v=m_wFEB4Oxlo]
== Credits
* Delano Mandelbaum (delano@solutious.com)
* Bernie Kopell (bernie@solutious.com)
== License
See LICENSE.txt
Changes:
DRYDOCK, CHANGES
#### 0.4 (2009-02-28) ###############################
* FIX: Bug, "interning empty string" error when bare "option" is used
* NEW: Calls valid? method (if present) before calling command block.
* NEW: "capture" method. Auto capture STDOUT to obj.stdout etc...
* NEW: Automatically calls init and print_header methods before the command
and print_footer after the command (if available)
* NEW: Tries to call obj.command if available when no block is supplied
* NEW: "show_commands" command built-in. Displays commands with descriptions
* NEW: A default usage help msg for every command: "#{$0} command-name"
* NEW: "usage" work multiple times for the same command.
* NEW: "desc" method for per command descriptions
* CHANGE: options are now stored as obj.option.name instead of obj.name
* CHANGE: global options are now stored as obj.globals.name
* CHANGE: removed auto importing methods
OLD: require 'drydock'
NEW: require 'drydock'
extend Drydock
#### 0.3.3 (2009-02-14) ###############################
* NEW: init method hook for subclasses of Drydock::Command
* UPDATED: Rdocs
* CHANGE: added method command_aliaz to mirror aliaz_command
#### 0.3 (2009-02-05) ###############################
* Added support for custom Drydock::Commands objects
* Global and command-specific options are now available as
attributes of the Drydock::Commands class instance.
* Automatic execution
* Now in a single file (lib/drydock.rb)
* Started adding tests
* Improved documentation
#### 0.2 (2008-12-27) ###############################
* Initial release
* Forked from bmizerany/frylock
|