class LastpassCLI::Agent
Attributes
config[R]
logged_in[R]
Public Class Methods
new()
click to toggle source
# File lib/lastpass-cli/agent.rb, line 5 def initialize @config = LastpassCLI.configuration end
Public Instance Methods
logged_in?()
click to toggle source
# File lib/lastpass-cli/agent.rb, line 29 def logged_in? command = [config.executable] command += Command.new.status out, _, _ = Open3.capture2e(*command) !!out.match('Logged in as') end
logged_out?()
click to toggle source
# File lib/lastpass-cli/agent.rb, line 36 def logged_out? !logged_in? end
login()
click to toggle source
# File lib/lastpass-cli/agent.rb, line 9 def login return true if logged_in? command = [config.executable] command += Command.new.login(username: config.username) out, _, _ = Open3.capture2e( { 'LPASS_DISABLE_PINENTRY' => '1' }, *command, stdin_data: "#{config.password}\n" ) !!out.match('Success: Logged in') end
logout()
click to toggle source
# File lib/lastpass-cli/agent.rb, line 21 def logout return true if logged_out? command = [config.executable] command += Command.new.logout out, _, _ = Open3.capture2e(*command) !!out.match('Log out: complete') end