Class: PDK::CLI::Util::CommandRedirector

Inherits:
TTY::Prompt::AnswersCollector
  • Object
show all
Defined in:
lib/pdk/cli/util/command_redirector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commandObject

Returns the value of attribute command.



7
8
9
# File 'lib/pdk/cli/util/command_redirector.rb', line 7

def command
  @command
end

Instance Method Details

#pastelObject



9
10
11
# File 'lib/pdk/cli/util/command_redirector.rb', line 9

def pastel
  @pastel ||= Pastel.new
end

#runObject



17
18
19
20
21
22
# File 'lib/pdk/cli/util/command_redirector.rb', line 17

def run
  @prompt.puts _('Did you mean \'%{command}\'?') % { command: pastel.bold(@command) }
  @prompt.yes?('-->')
rescue TTY::Prompt::Reader::InputInterrupt
  nil
end

#target_command(cmd) ⇒ Object



13
14
15
# File 'lib/pdk/cli/util/command_redirector.rb', line 13

def target_command(cmd)
  @command = cmd
end