Files | Admin

Notes:

Release Name: 0.6.2

Notes:
= Drydock - v0.6

<b>Build seaworthy command-line apps like a Captain with a powerful Ruby DSL.</b>

== Overview

Drydock is a seaworthy DSL for building really powerful command line applications. The core class is contained in a single .rb file so it's easy to copy directly into your project. See below for examples. 

== 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]

== Thanks

* Solutious Inc for putting up with my endless references to the sea! (http://solutious.com)
* Blake Mizerany for the inspiration via bmizerany-frylock[http://github.com/bmizerany/frylock]

== Credits

* Delano Mandelbaum (delano@solutious.com)
* Bernie Kopell (bernie@solutious.com)

== License

See LICENSE.txt



Changes: DRYDOCK, CHANGES #### TODO ############################### * Support putting descriptions into resource file (or __END__) #### 0.6.1 (2009-05-03) ############################# * FIXED: @@trawler raises an error in Ruby 1.8 if it's a Symbol #### 0.6.0 (2009-04-30) ############################# * CHANGE: Cleaner default error message for UnknownCommand exceptions * CHANGE: 'desc' is now 'about' (desc works, but it prints a notice) * CHANGE: I now recommend implementing the Drydock DSL in a module. bin/example was updated to reflect the change. This prevents Drydock keywords from being included in the global namespace. * ADDED: Inline commands aliases. command :cmd1, :cmd2 do; ...; end * ADDED: Unknown commands can be directed to a trawler. #### 0.5.6 (2009-04-22) ############################# * CHANGED: Interrupts now handled in rescue rather than a trap. * ADDED: Drydock::ArgError and Drydock::OptError are rescued at runtime by default #### 0.5.5 (2009-04-19) ############################# * CHANGED: Improved help screen formatting. #### 0.5.4 (2009-04-15) ############################# * ADDED: Better error handling with new Drydock::ArgError and Drydock::OptError #### 0.5.3 (2009-04-05) ############################# * FIXED: Command actions were not being handled correctly. Added rdocs to clarify the code. #### 0.5.2 (2009-04-04) ############################# * ADDED: before and after blocks now receive a primed reference to the command object (which gives them access to the globals and options) * CHANGE: The prep stuff in Drydock::Command#call is now split into a separate method: prepare so call no longer takes arguments. * FIXED: Drydock#capture_io was using yield. It now accepts a block instead. #### 0.5.1 (2009-03-15) ############################# * FIXED: Prevent calling default command in at_exit when there's a LoadError. * FIXED: Exit gracefully when the application exits. * FIXED: Print command names with dashes rather than underscores #### 0.5 (2009-03-11) ############################### * ADDED: Checks that the command class is a subclass of Drydock::Command * CHANGE: Cleaned up show-commands screen * FIXED: Help didn't work when using command alias * ADDED: Named argv values. * CHANGE: argv are now part of the Command class (not passed to command blocks) * CHANGE: "project" now automatically requires the lowercase name of the project and gracefully continues if the require failed. * CHANGE: Drydock will look for different validation method, based on the method being executed. If a validation method is found it's executed and must return a true valid (it can also raise its own exceptions). * ADDED: command actions. These are boolean switches with a twist. Drydock looks for command_action or action_command methods. Saves checking the switches and sending to other methods manually. #### 0.4 (2009-02-28) ############################### * FIXED: "interning empty string" error when bare "option" is used * ADDED: Calls valid? method (if present) before calling command block. * ADDED: "capture" method. Auto capture STDOUT to obj.stdout etc... * ADDED: Automatically calls init and print_header methods before the command and print_footer after the command (if available) * ADDED: Tries to call obj.command if available when no block is supplied * ADDED: "show_commands" command built-in. Displays commands with descriptions * ADDED: A default usage help msg for every command: "#{$0} command-name" * ADDED: "usage" work multiple times for the same command. * ADDED: "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' ADDED: require 'drydock' extend Drydock #### 0.3.3 (2009-02-14) ############################### * ADDED: 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