Class: PDK::CLI::Util::CommandRedirector
- Inherits:
-
TTY::Prompt::AnswersCollector
- Object
- TTY::Prompt::AnswersCollector
- PDK::CLI::Util::CommandRedirector
- Defined in:
- lib/pdk/cli/util/command_redirector.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
Instance Method Summary collapse
-
#initialize(prompt, options = {}) ⇒ CommandRedirector
constructor
Override the initialize method because the original one doesn’t work with Ruby 3.
-
#pastel ⇒ Object
rubocop:enable Lint/MissingSuper.
- #run ⇒ Object
- #target_command(cmd) ⇒ Object
Constructor Details
#initialize(prompt, options = {}) ⇒ CommandRedirector
Override the initialize method because the original one doesn’t work with Ruby 3. rubocop:disable Lint/MissingSuper
13 14 15 16 |
# File 'lib/pdk/cli/util/command_redirector.rb', line 13 def initialize(prompt, = {}) @prompt = prompt @answers = .fetch(:answers) { {} } end |
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
8 9 10 |
# File 'lib/pdk/cli/util/command_redirector.rb', line 8 def command @command end |
Instance Method Details
#pastel ⇒ Object
rubocop:enable Lint/MissingSuper
19 20 21 |
# File 'lib/pdk/cli/util/command_redirector.rb', line 19 def pastel @pastel ||= Pastel.new end |
#run ⇒ Object
27 28 29 30 31 32 |
# File 'lib/pdk/cli/util/command_redirector.rb', line 27 def run @prompt.puts "Did you mean '#{pastel.bold(@command)}'?" @prompt.yes?('-->') rescue PDK::CLI::Util::Interview::READER::InputInterrupt nil end |
#target_command(cmd) ⇒ Object
23 24 25 |
# File 'lib/pdk/cli/util/command_redirector.rb', line 23 def target_command(cmd) @command = cmd end |