Class: CarbonMU::CLI
- Inherits:
-
Object
- Object
- CarbonMU::CLI
- Defined in:
- lib/carbonmu/cli.rb
Constant Summary collapse
- COMMAND_WHITELIST =
["start", "start_server_only"]
- USAGE =
"Usage: carbonmu start\n"
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(argv) ⇒ CLI
constructor
A new instance of CLI.
- #start ⇒ Object
- #start_server_only(port) ⇒ Object
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
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
3 4 5 |
# File 'lib/carbonmu/cli.rb', line 3 def argv @argv end |
Instance Method Details
#execute ⇒ Object
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 |
#start ⇒ Object
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 |