Class: Hyraft::Rule::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/hyraft/rule/command.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Command

Returns a new instance of Command.



10
11
12
13
14
# File 'lib/hyraft/rule/command.rb', line 10

def initialize(argv)
  @argv = argv
  @command = argv[0]
  @args = argv[1..-1]
end

Class Method Details

.start(argv) ⇒ Object



6
7
8
# File 'lib/hyraft/rule/command.rb', line 6

def self.start(argv)
  new(argv).execute
end

Instance Method Details

#executeObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/hyraft/rule/command.rb', line 16

def execute
  case @command
  when "migrate"
    MigrationCommand.start(@args)
  when "source"
    SourceCommand.start(@args)
  when "circuit"
    CircuitCommand.start(@args)
  when "port"
    PortCommand.start(@args)
  when "web-adapter"
    AdapterRequest::WebAdapterCommand.start(@args)
  when "data-gateway"
    AdapterExhaust::DataGatewayCommand.start(@args)
  when "assemble"
    AssembleCommand.start(@args)
  when "disassemble"  
    DisassembleCommand.start(@args)
  when "template" 
    TemplateCommand.start(@args)
  when "remove-adapter", "rm-adapter"
    require 'hyraft/rule/adapter_request/remove_adapter_command'
    RemoveAdapterCommand.start(@args)
  when "version", "-v", "--version"
    puts "Hyraft Rule version #{VERSION}"
  when "help", "-h", "h", "--help", nil
    show_help
  else
    puts "Unknown command: #{@command}"
    show_help
  end
end