Canine is a library for creating basic Ruby "binaries," a la the rails
, monk
, and jekyll
executables. It's as easy as passing a block:
require 'canine'
Canine.new do
# code here
end
And it will auto-magically run.
Now, the things you can do are pretty simple:
command name, [desc], &block
=> creates a new command with the given name. The block can take as many arguments as you want, provided you define them withoptions
later in the scriptcommand name, autocommand-name
=> links an auto-command to the given name. At the moment, there's only one,commands
. If more are added, they'll be in the@auto
hashno_command desc, &block
=> if you want a command to be run when arguments are simply passed (as inrails <myapp>
), pass a description and a block to this methodno_command name
=> should you want the commandless process to be a command you already created, pass the name to the methodoptions hash
=> set up the options for the latest command that you created, in an'name' => 'description'
formatdefault_command name
=> set the command you want to run when no arguments are passed the the script. This is required.
The command blocks themselves can do anything. You can import anything you really need, from fileutils
to rake
, and use them within the commands.