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

#hook_descriptionsObject


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

def hook_descriptions
  {
    resolve_reference: 'Prompt the user for a sensitive value.',
    validate_resolve_reference: nil
  }
end

#hooksObject


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

def hooks
  hook_descriptions.keys
end

#nameObject


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

def name
  'prompt'
end

#resolve_reference(opts) ⇒ Object


27
28
29
30
31
32
33
# File 'lib/bolt/plugin/prompt.rb', line 27

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

  value
end

#validate_resolve_reference(opts) ⇒ Object


23
24
25
# File 'lib/bolt/plugin/prompt.rb', line 23

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