Class: Opscode::CLI

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv, opts = {}) ⇒ CLI

Returns a new instance of CLI.



9
10
11
12
13
# File 'lib/opscode.rb', line 9

def initialize(argv, opts = {})
  @stdout_io = opts[:stdout_io] || $stdout
  @scm = opts[:scm] || "git"
  @argv = Array(argv)
end

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.



7
8
9
# File 'lib/opscode.rb', line 7

def argv
  @argv
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
# File 'lib/opscode.rb', line 15

def run
  case argv.first
  when "version", "--version", "-v", "-version"
    stdout_io.puts "Opscode version #{Opscode::VERSION}"
  else
    exec(scm, *argv)
  end
end