class Dandelion::Command::Base
Attributes
config[R]
options[R]
workspace[R]
Public Class Methods
command(name)
click to toggle source
# File lib/dandelion/command.rb, line 11 def command(name) @@commands[name] = self end
commands()
click to toggle source
# File lib/dandelion/command.rb, line 15 def commands @@commands.keys end
lookup(name)
click to toggle source
# File lib/dandelion/command.rb, line 19 def lookup(name) raise InvalidCommandError.new(name) unless @@commands[name] @@commands[name] end
new(workspace, config, options = {})
click to toggle source
# File lib/dandelion/command.rb, line 65 def initialize(workspace, config, options = {}) @workspace = workspace @config = config @options = options end
parser(options)
click to toggle source
# File lib/dandelion/command.rb, line 24 def parser(options) OptionParser.new do |opts| opts.banner = 'Usage: dandelion [options] <command> [<args>]' options[:version] = false opts.on('-v', '--version', 'Dispay the current version') do options[:version] = true end options[:help] = false opts.on('-h', '--help', 'Display this help info') do options[:help] = true end options[:repo] = nil opts.on('--repo=[REPO]', 'Use the given repository') do |repo| options[:repo] = repo end options[:config] = nil opts.on('--config=[CONFIG]', 'Use the given config file') do |config| options[:config] = config end opts.on('--log=[level]', 'Use the given log level (fatal, error, warn, info, debug)') do |level| levels = { fatal: Logger::FATAL, error: Logger::ERROR, warn: Logger::WARN, info: Logger::INFO, debug: Logger::DEBUG } Dandelion.logger.level = levels[level.to_sym] end end end
Public Instance Methods
adapter()
click to toggle source
# File lib/dandelion/command.rb, line 74 def adapter workspace.adapter end
log()
click to toggle source
# File lib/dandelion/command.rb, line 78 def log Dandelion.logger end
setup(args)
click to toggle source
# File lib/dandelion/command.rb, line 71 def setup(args) end