Class: HostListThor

Inherits:
Thor
  • Object
show all
Defined in:
lib/hostlist/thor.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



11
12
13
14
# File 'lib/hostlist/thor.rb', line 11

def method_missing(method, *args)
  args = ['list', method.to_s] + args
  HostListThor.start(args)
end

Instance Method Details

#list(*tags) ⇒ Object



17
18
19
20
# File 'lib/hostlist/thor.rb', line 17

def list(*tags)
  hostlist = HostList.new(yaml: options[:yaml], cache: options[:db])
  hostlist.list(tags).each { |host| puts host }
end


29
30
31
32
# File 'lib/hostlist/thor.rb', line 29

def print_db
  hostlist = HostList.new(yaml: options[:yaml], cache: options[:db])
  hostlist.print_db
end

#showObject



23
24
25
26
# File 'lib/hostlist/thor.rb', line 23

def show
  hostlist = HostList.new(yaml: options[:yaml], cache: options[:db])
  hostlist.keys.each { |key| puts key }
end