Class: PerfMonger::Command::BaseCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/perfmonger/command/base_command.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBaseCommand

Returns a new instance of BaseCommand.



28
29
30
31
32
33
34
35
# File 'lib/perfmonger/command/base_command.rb', line 28

def initialize
  @parser = OptionParser.new
  @parser.banner = "Usage: \#{File.basename($0)} \#{self.class.command_name} [options]\n\nOptions:\n"
end

Class Attribute Details

.aliasesObject

Returns the value of attribute aliases.



9
10
11
# File 'lib/perfmonger/command/base_command.rb', line 9

def aliases
  @aliases
end

.command_nameObject

Returns the value of attribute command_name.



7
8
9
# File 'lib/perfmonger/command/base_command.rb', line 7

def command_name
  @command_name
end

.descriptionObject

Returns the value of attribute description.



8
9
10
# File 'lib/perfmonger/command/base_command.rb', line 8

def description
  @description
end

Class Method Details

.register_alias(alias_name) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/perfmonger/command/base_command.rb', line 17

def register_alias(alias_name)
  if self.command_name
    RuntimeError.new("#{self} does not have registered command name.")
  end

  self.aliases ||= []
  self.aliases.push(alias_name)
  PerfMonger::CLI::Runner.register_alias(alias_name, self.command_name)
end

.register_command(command_name, description = "") ⇒ Object



11
12
13
14
15
# File 'lib/perfmonger/command/base_command.rb', line 11

def register_command(command_name, description = "")
  PerfMonger::CLI::Runner.register_command(command_name, self)
  self.command_name = command_name
  self.description = description
end