Class: Chef::Fork::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/chef/fork/application.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApplication

Returns a new instance of Application.



13
14
15
16
17
18
19
# File 'lib/chef/fork/application.rb', line 13

def initialize()
  @logger = Logger.new(STDERR)
  @optparse = OptionParser.new
  @optparse.version = "#{Chef::Fork::VERSION} (chef #{Chef::VERSION})"
  @options = {}
  define_options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



20
21
22
# File 'lib/chef/fork/application.rb', line 20

def options
  @options
end

#optparseObject (readonly)

Returns the value of attribute optparse.



21
22
23
# File 'lib/chef/fork/application.rb', line 21

def optparse
  @optparse
end

Instance Method Details

#configure(options = {}) ⇒ Object



33
34
35
# File 'lib/chef/fork/application.rb', line 33

def configure(options={})
  configure_chef(locate_config_file("fork") || locate_config_file("knife"), options)
end

#main(args = []) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/chef/fork/application.rb', line 23

def main(args=[])
  rest = @optparse.order(args)
  begin
    command = get_command(rest.shift || "help").new(self)
    command.run(rest)
  rescue Errno::EPIPE
    # noop
  end
end