Class: Bolt::Plugin::Prompt

Inherits:
Object
  • Object
show all
Defined in:
lib/bolt/plugin/prompt.rb

Instance Method Summary collapse

Constructor Details

#initialize(*_args) ⇒ Prompt

Returns a new instance of Prompt.



6
# File 'lib/bolt/plugin/prompt.rb', line 6

def initialize(*_args); end

Instance Method Details

#hooksObject



12
13
14
# File 'lib/bolt/plugin/prompt.rb', line 12

def hooks
  %i[resolve_reference validate_resolve_reference]
end

#nameObject



8
9
10
# File 'lib/bolt/plugin/prompt.rb', line 8

def name
  'prompt'
end

#resolve_reference(opts) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/bolt/plugin/prompt.rb', line 20

def resolve_reference(opts)
  STDERR.print("#{opts['message']}: ")
  value = STDIN.noecho(&:gets).to_s.chomp
  STDERR.puts

  value
end

#validate_resolve_reference(opts) ⇒ Object



16
17
18
# File 'lib/bolt/plugin/prompt.rb', line 16

def validate_resolve_reference(opts)
  raise Bolt::ValidationError, "Prompt requires a 'message'" unless opts['message']
end