Class: LastpassCLI::Command
- Inherits:
-
Object
- Object
- LastpassCLI::Command
- Defined in:
- lib/lastpass-cli/command.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add(name:, sync: 'now', note_type: nil) ⇒ Object
- #login(username:, trust: false, plaintext_key: false, force: false) ⇒ Object
- #logout(force: true) ⇒ Object
- #ls(sync: 'now') ⇒ Object
- #show(name:, sync: 'now', expand_multi: true) ⇒ Object
- #status(quiet: false) ⇒ Object
Class Method Details
.run(args, stdin_data: nil) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/lastpass-cli/command.rb', line 5 def self.run(args, stdin_data: nil) raise unless Agent.new.login command = [LastpassCLI.configuration.executable] command += args out, _, _ = Open3.capture2e(*command, stdin_data: stdin_data) out rescue StandardError => e raise "Failed to execute:\n#{command}\nError: #{e}" end |
Instance Method Details
#add(name:, sync: 'now', note_type: nil) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/lastpass-cli/command.rb', line 50 def add(name:, sync: 'now', note_type: nil) raise unless %w[auto now no].include?(sync) args = ['add', '--non-interactive'] args << "--sync=#{sync}" args << "--note-type=#{note_type}" if note_type args << name end |
#login(username:, trust: false, plaintext_key: false, force: false) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/lastpass-cli/command.rb', line 15 def login(username:, trust: false, plaintext_key: false, force: false) args = ['login', username] args << '--plaintext-key' if plaintext_key args << '--force' if force args end |
#logout(force: true) ⇒ Object
22 23 24 25 26 |
# File 'lib/lastpass-cli/command.rb', line 22 def logout(force: true) args = ['logout'] args << '--force' if force args end |
#ls(sync: 'now') ⇒ Object
28 29 30 31 32 33 |
# File 'lib/lastpass-cli/command.rb', line 28 def ls(sync: 'now') raise unless %w[auto now no].include?(sync) args = ['ls', '--long'] args << "--sync=#{sync}" args end |
#show(name:, sync: 'now', expand_multi: true) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/lastpass-cli/command.rb', line 41 def show(name:, sync: 'now', expand_multi: true) raise unless %w[auto now no].include?(sync) args = ['show', '--all'] args << "--sync=#{sync}" args << '--expand-multi' if args << name args end |
#status(quiet: false) ⇒ Object
35 36 37 38 39 |
# File 'lib/lastpass-cli/command.rb', line 35 def status(quiet: false) args = ['status'] args << '--quiet' if quiet args end |