Class: Front::CLI::Controller

Inherits:
Object
  • Object
show all
Includes:
Loader
Defined in:
lib/front/cli/controller.rb

Constant Summary

Constants included from Loader

Loader::LIB_DIR, Loader::ROOT_DIR

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Controller

Returns a new instance of Controller.



12
13
14
15
# File 'lib/front/cli/controller.rb', line 12

def initialize(options)
  @options = options
  @pool = VagrantPool.new(options.pool_size)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



67
68
69
# File 'lib/front/cli/controller.rb', line 67

def method_missing(method)
  show_error "Unknown action: #{method}"
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/front/cli/controller.rb', line 10

def options
  @options
end

Instance Method Details

#createObject

actions



18
19
20
21
# File 'lib/front/cli/controller.rb', line 18

def create
  @pool.create
  @pool.load
end

#destroyObject



23
24
25
# File 'lib/front/cli/controller.rb', line 23

def destroy
  @pool.unload
end

#inventoryObject



39
40
41
# File 'lib/front/cli/controller.rb', line 39

def inventory
  puts File.read(@pool.get_inventory_file())
end

#nextObject



27
28
29
# File 'lib/front/cli/controller.rb', line 27

def next
  @pool.next
end

#show_error(msg = @options.error) ⇒ Object



60
61
62
63
64
65
# File 'lib/front/cli/controller.rb', line 60

def show_error(msg = @options.error)
  puts "Error: #{msg}"
  puts

  show_help
end

#show_helpObject

help



72
73
74
# File 'lib/front/cli/controller.rb', line 72

def show_help
  puts @options.opts
end

#show_invalid_optionObject

errors



48
49
50
# File 'lib/front/cli/controller.rb', line 48

def show_invalid_option
  show_error @options.error
end

#show_missing_argsObject



52
53
54
# File 'lib/front/cli/controller.rb', line 52

def show_missing_args
  show_error @options.error
end

#show_parser_errorObject



56
57
58
# File 'lib/front/cli/controller.rb', line 56

def show_parser_error
  show_error @options.error
end

#show_versionObject



76
77
78
# File 'lib/front/cli/controller.rb', line 76

def show_version
  puts VERSION
end

#sshObject



31
32
33
# File 'lib/front/cli/controller.rb', line 31

def ssh
  @pool.ssh
end

#ssh_configObject



35
36
37
# File 'lib/front/cli/controller.rb', line 35

def ssh_config
  puts @pool.ssh_config
end

#statusObject



43
44
45
# File 'lib/front/cli/controller.rb', line 43

def status
  @pool.status
end