Class: Bard::CLI::Command

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/bard/cli/command.rb

Direct Known Subclasses

New, Provision

Class Method Summary collapse

Class Method Details

.desc(command, description) ⇒ Object



4
5
6
7
8
# File 'lib/bard/cli/command.rb', line 4

def self.desc command, description
  @command = command
  @method = command.split(" ").first.to_sym
  @description = description
end

.setup(cli) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/bard/cli/command.rb', line 10

def self.setup cli
  cli.desc @command, @description
  # put in local variables so next block can capture it
  command_class = self
  method = @method
  cli.define_method method do |*args|
    command = command_class.new(self)
    command.send method, *args
  end
end