Class: OnePass::Password
- Inherits:
-
Object
- Object
- OnePass::Password
- Defined in:
- lib/OnePass/password.rb
Overview
Fork out to ‘pinentry` for password
Constant Summary collapse
- DESCRIPTION =
'Please enter your 1Password master password for the following vault:'.freeze
- DEFAULT =
{ title: '1Password CLI', prompt: 'Master Password: ' }.freeze
Instance Method Summary collapse
- #done ⇒ Object
-
#initialize(opts = {}) ⇒ Password
constructor
A new instance of Password.
- #prompt(error_message = nil) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Password
Returns a new instance of Password.
12 13 14 15 16 17 |
# File 'lib/OnePass/password.rb', line 12 def initialize(opts = {}) @config = OpenStruct.new DEFAULT.merge(opts) if @config.vault_path @config.description ||= "#{DESCRIPTION}%0a#{@config.vault_path}" end end |
Instance Method Details
#done ⇒ Object
28 29 30 31 |
# File 'lib/OnePass/password.rb', line 28 def done send 'BYE' @pipe.close end |
#prompt(error_message = nil) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/OnePass/password.rb', line 19 def prompt( = nil) @config.error = @pipe = IO.popen 'pinentry', 'r+' check send_settings fetch_password @password end |