Class: Ora::Cli::Bash

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, from: nil, print: Print.new) ⇒ Bash

Returns a new instance of Bash.



8
9
10
11
12
13
14
# File 'lib/ora/cli/bash.rb', line 8

def initialize(target, from: nil, print: Print.new)
  @target               = target
  @from                 = from
  @print                = print
  @success              = true
  @unprocessed_commands = []
end

Instance Attribute Details

#unprocessed_commandsObject (readonly)

Returns the value of attribute unprocessed_commands.



6
7
8
# File 'lib/ora/cli/bash.rb', line 6

def unprocessed_commands
  @unprocessed_commands
end

Instance Method Details

#run(commands) ⇒ Object



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/ora/cli/bash.rb', line 20

def run commands
  @success = true
  @unprocessed_commands = extract commands

  outputs = []
  command = ''
  while (command = complete @unprocessed_commands.shift)
    next if command.empty?

    if method? command
      sub_commands = call_method command
      @unprocessed_commands.unshift(*extract(sub_commands))
    else
      @success, output = shell command
      outputs.push output
      break unless @success
    end
  end

  @unprocessed_commands.unshift(command) unless @success

  join outputs
end

#select(command) ⇒ Object



44
45
46
# File 'lib/ora/cli/bash.rb', line 44

def select command
  `#{move}#{command} | #{Path.selecta}`.strip
end

#silent(command) ⇒ Object



16
17
18
# File 'lib/ora/cli/bash.rb', line 16

def silent command
  `#{move}#{command}#{capture_err}`
end

#success?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/ora/cli/bash.rb', line 48

def success?
  @success
end