Skip to content

Commit

Permalink
teach bitwarden lookup how to sync
Browse files Browse the repository at this point in the history
set sync=true in the lookup call to call `bw sync` before looking up
data
  • Loading branch information
larsks committed Oct 20, 2018
1 parent e5dd4ea commit c56f7b5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lookup_plugins/bitwarden.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
custom_field:
description: If True, look up named field in custom fields instead
of top-level dictionary.
sync:
description: If True, call `bw sync` before lookup
"""

EXAMPLES = """
Expand Down Expand Up @@ -103,6 +105,9 @@ def _run(self, args):
"{0}".format(out))
return out.strip()

def sync(self):
self._run(['sync'])

def get_entry(self, key, field):
return self._run(["get", field, key]).decode('utf-8')

Expand All @@ -123,6 +128,10 @@ def run(self, terms, variables=None, **kwargs):

field = kwargs.get('field', 'password')
values = []

if kwargs.get('sync'):
bw.sync()

for term in terms:
if kwargs.get('custom_field'):
values.append(bw.get_custom_field(term, field))
Expand Down

0 comments on commit c56f7b5

Please sign in to comment.