Browse Source

bitwarden: make search-str optional

If not given, then return all items.
Sean Farley 7 years ago
parent
commit
b8bc636e3d
1 changed files with 9 additions and 3 deletions
  1. 9 3
      bitwarden.el

+ 9 - 3
bitwarden.el

@@ -304,15 +304,21 @@ printed to minibuffer."
    print-message))
    print-message))
 
 
 ;;;###autoload
 ;;;###autoload
-(defun bitwarden-search (search-str)
+(defun bitwarden-search (&optional search-str)
   "Search for vault for items containing SEARCH-STR.
   "Search for vault for items containing SEARCH-STR.
 
 
 If run interactively PRINT-MESSAGE gets set and password is
 If run interactively PRINT-MESSAGE gets set and password is
 printed to minibuffer.
 printed to minibuffer.
 
 
 Returns a vector of hashtables of the results."
 Returns a vector of hashtables of the results."
-  (let* ((ret (bitwarden--auto-cmd (list "list" "items" "--search"
-                                         search-str)))
+  (let* ((args (and search-str (list "--search" search-str)))
+         (ret (bitwarden--auto-cmd (append (list "list" "items") args)))
+         (result (bitwarden--handle-message ret)))
+    (when result
+      (let* ((json-object-type 'hash-table)
+             (json-key-type 'string)
+             (json (json-read-from-string result)))
+           json))))
          (result (bitwarden--handle-message ret t)))
          (result (bitwarden--handle-message ret t)))
     (when result
     (when result
       (let* ((json-object-type 'hash-table)
       (let* ((json-object-type 'hash-table)