Module: Shake::Defaults

Included in:
Shake
Defined in:
lib/shake.rb

Overview

This is a list of default commands. The class Shake itself uses this, but if you subclass it, you will have to do ‘include Defaults` yourself.

Class Method Summary collapse

Class Method Details

.included(to) ⇒ Object



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/shake.rb', line 160

def self.included(to)
  to.default :help

  to.task(:help) {
    err "Usage: #{executable} <command>"
    err
    err "Commands:"
    tasks.each { |name, task| err "  %-20s %s" % [ task.usage || name, task.description ] }
  }

  to.task(:help).description = "Shows a list of commands"

  to.invalid {
    if task(command)
      usage = task(command).usage
      err "Invalid usage."
      err "Usage: `#{executable} #{usage}`\n"  if usage
      err "See `#{executable} help` for more info."
    else
      err "Unknown command: #{command}"
      err "See `#{executable} help` for a list of commands."
    end
  }
end