Class: CarbonMU::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/carbonmu/cli.rb

Constant Summary collapse

COMMAND_WHITELIST =
["start", "start_server_only"]
USAGE =
"Usage: carbonmu start\n"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI

Returns a new instance of CLI.



5
6
7
# File 'lib/carbonmu/cli.rb', line 5

def initialize(argv)
  @argv = argv
end

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.



3
4
5
# File 'lib/carbonmu/cli.rb', line 3

def argv
  @argv
end

Instance Method Details

#executeObject



9
10
11
12
13
14
15
16
17
# File 'lib/carbonmu/cli.rb', line 9

def execute
  if @argv.length == 0 || !COMMAND_WHITELIST.include?(@argv[0])
    puts USAGE
    exit(1)
  end

  command = @argv.shift
  send(command, *@argv)
end

#startObject



19
20
21
# File 'lib/carbonmu/cli.rb', line 19

def start
  CarbonMU.start
end

#start_server_only(port) ⇒ Object



23
24
25
26
# File 'lib/carbonmu/cli.rb', line 23

def start_server_only(port)
  CarbonMU.edge_router_receive_port = port
  CarbonMU.start_server
end