Class: ChefSearch::CLI

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

Overview

CLI execution

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) ⇒ CLI

setup CLI options



11
12
13
14
15
# File 'lib/chefsearch/cli.rb', line 11

def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR,
  kernel = Kernel)
  @argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout,
                                             stderr, kernel
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



8
9
10
# File 'lib/chefsearch/cli.rb', line 8

def opts
  @opts
end

Instance Method Details

#execute!Object

Run the CLI command



18
19
20
21
22
23
24
25
26
# File 'lib/chefsearch/cli.rb', line 18

def execute!
  parse_options

  c = ChefSearch::Search.new(@opts.config)
  puts c.search(name: @opts.name,
                role: @opts.role,
                chef_environment: @opts.environment
                )
end