Module: GClouder::Shell

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

#add, #bad, #change, #debug, #error, #fatal, #good, #info, log, loggers, #remove, report, #resource_state, setup, #warn, #warning

Class Method Details

.included(klass) ⇒ Object



9
10
11
# File 'lib/gclouder/shell.rb', line 9

def self.included(klass)
  klass.extend Shell
end

Instance Method Details

#shell(command, failure: true, silent: false) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/gclouder/shell.rb', line 13

def shell(command, failure: true, silent: false)
  stdout, stderr, status, failed = run(command)

  if (GClouder.cli_args[:debug] || failed) && !silent
    header(command)
    dump_fds(stdout, stderr)
  end

  if !failed && silent
    return true
  end

  if failed && !failure
    return false
  end

  if failed && silent
    return false
  end

  if failed && !silent
    footer(status)
  end

  if silent
    return
  end

  stdout
end