Class: Kumade::CLI

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

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = ARGV, out = StringIO.new) ⇒ CLI

Returns a new instance of CLI.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/kumade/cli.rb', line 14

def initialize(args = ARGV, out = StringIO.new)
  @options     = {}
  parse_arguments!(args)

  Kumade.configuration.pretending  = !!@options[:pretend]
  Kumade.configuration.environment = args.shift

  self.class.swapping_stdout_for(out, print_output?) do
    deploy
  end
end

Class Attribute Details

.deployerObject



9
10
11
# File 'lib/kumade/cli.rb', line 9

def deployer
  @deployer || Kumade::Deployer
end

Class Method Details

.swapping_stdout_for(io, print_output = false) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/kumade/cli.rb', line 26

def self.swapping_stdout_for(io, print_output = false)
  if print_output
    yield
  else
    begin
      real_stdout = $stdout
      $stdout     = io
      yield
    rescue Kumade::DeploymentError
      io.rewind
      real_stdout.print(io.read)
    ensure
      $stdout = real_stdout
    end
  end
end