Class: Dandelion::Command::Base
- Inherits:
-
Object
- Object
- Dandelion::Command::Base
- Defined in:
- lib/dandelion/command.rb
Constant Summary collapse
- @@commands =
{}
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#workspace ⇒ Object
readonly
Returns the value of attribute workspace.
Class Method Summary collapse
Instance Method Summary collapse
- #adapter ⇒ Object
-
#initialize(workspace, config, options = {}) ⇒ Base
constructor
A new instance of Base.
- #log ⇒ Object
- #setup(args) ⇒ Object
Constructor Details
#initialize(workspace, config, options = {}) ⇒ Base
Returns a new instance of Base.
65 66 67 68 69 |
# File 'lib/dandelion/command.rb', line 65 def initialize(workspace, config, = {}) @workspace = workspace @config = config @options = end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
63 64 65 |
# File 'lib/dandelion/command.rb', line 63 def config @config end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
63 64 65 |
# File 'lib/dandelion/command.rb', line 63 def @options end |
#workspace ⇒ Object (readonly)
Returns the value of attribute workspace.
63 64 65 |
# File 'lib/dandelion/command.rb', line 63 def workspace @workspace end |
Class Method Details
.command(name) ⇒ Object
11 12 13 |
# File 'lib/dandelion/command.rb', line 11 def command(name) @@commands[name] = self end |
.commands ⇒ Object
15 16 17 |
# File 'lib/dandelion/command.rb', line 15 def commands @@commands.keys end |
.lookup(name) ⇒ Object
19 20 21 22 |
# File 'lib/dandelion/command.rb', line 19 def lookup(name) raise InvalidCommandError.new(name) unless @@commands[name] @@commands[name] end |
.parser(options) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/dandelion/command.rb', line 24 def parser() OptionParser.new do |opts| opts. = 'Usage: dandelion [options] <command> [<args>]' [:version] = false opts.on('-v', '--version', 'Dispay the current version') do [:version] = true end [:help] = false opts.on('-h', '--help', 'Display this help info') do [:help] = true end [:repo] = nil opts.on('--repo=[REPO]', 'Use the given repository') do |repo| [:repo] = repo end [:config] = nil opts.on('--config=[CONFIG]', 'Use the given config file') do |config| [: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 |
Instance Method Details
#adapter ⇒ Object
74 75 76 |
# File 'lib/dandelion/command.rb', line 74 def adapter workspace.adapter end |
#setup(args) ⇒ Object
71 72 |
# File 'lib/dandelion/command.rb', line 71 def setup(args) end |