4f90849425b4f40778e2fdb5281a1bae4117a7c2

Author
Mark Mercado <mamercad@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(lpass): add plugin for LastPass CLI completion (#9323)

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/lpass/README.md b/plugins/lpass/README.md
  2new file mode 100644
  3index 0000000000000000000000000000000000000000..d3923ea67558d3eb23bdb0eea2112603d3d4623a
  4--- /dev/null
  5+++ b/plugins/lpass/README.md
  6@@ -0,0 +1,13 @@
  7+# lpass (LastPass CLI)
  8+
  9+This plugin adds completion for LastPass CLI [`lpass`](https://github.com/lastpass/lastpass-cli).
 10+
 11+To use it, add `lpass` to the plugins array in your zshrc file:
 12+
 13+```zsh
 14+plugins=(... lpass)
 15+```
 16+
 17+Completion is taken from the `lpass` release [`1.3.3`](https://github.com/lastpass/lastpass-cli/releases/tag/v1.3.3).
 18+
 19+Updated on October 9th, 2020.
 20diff --git a/plugins/lpass/_lpass b/plugins/lpass/_lpass
 21new file mode 100644
 22index 0000000000000000000000000000000000000000..e6193a22d74bc2d6d3f3096d520c1b0295dfc5b1
 23--- /dev/null
 24+++ b/plugins/lpass/_lpass
 25@@ -0,0 +1,169 @@
 26+#compdef lpass
 27+
 28+_lpass() {
 29+    local cmd has_color has_sync has_interactive
 30+  	if (( CURRENT > 2)); then
 31+        cmd=${words[2]}
 32+        # Set the context for the subcommand.
 33+        curcontext="${curcontext%:*:*}:lpass-$cmd"
 34+        # Narrow the range of words we are looking at to exclude `lpass'
 35+        (( CURRENT-- ))
 36+        shift words
 37+        # Run the completion for the subcommand
 38+        case "${cmd}" in
 39+            login)
 40+                _arguments : \
 41+                  '--trust[Cause subsequent logins to not require multifactor authentication.]' \
 42+                  '--plaintext-key[Save plaintext decryption key to the hard disk]' \
 43+                  '--force[Do not ask on saving plaintext key]'
 44+                has_color=1
 45+            ;;
 46+
 47+            logout)
 48+                _arguments : '--force[Force confirmation]'
 49+                has_color=1
 50+            ;;
 51+            show)
 52+                _arguments : \
 53+                  '(-c --clip)'{-c,--clip}'[Copy output to clipboard]' \
 54+                  '(-x --expand-multi)'{-x,---expand-multi}'[Show the requested information from all of the matching sites]' \
 55+                  '(--all --username --password --url --notes --field= --id --name --attach=)'{--all,--username,--password,--url,--notes,--field=,--id,--name,--attach=}'[Output the specific field]' \
 56+                  '(--basic-regexp,--fixed-string)'{-G,--basic-regexp}'[Find a site by substring or regular expression]' \
 57+                  '--format=[Format output with printf-style placeholders]'
 58+                _lpass_complete_uniqenames
 59+                has_color=1
 60+                has_sync=1
 61+            ;;
 62+
 63+            ls)
 64+                _arguments : \
 65+                  '(-l --long)'{-l,--long}'[Also list the last modification time and username]' \
 66+                  '-u[List username]' \
 67+                  '-m[List modification time]' \
 68+                  '--format=[Format output with printf-style placeholders]'
 69+      				  _lpass_complete_groups
 70+                has_color=1
 71+                has_sync=1
 72+      			;;
 73+            mv)
 74+                _lpass_complete_uniqenames
 75+                _lpass_complete_groups
 76+                has_color=1
 77+            ;;
 78+            duplicate|rm)
 79+                _lpass_complete_uniqenames
 80+                has_color=1
 81+                has_sync=1
 82+            ;;
 83+            add)
 84+                _arguments : '(--username --password --url --notes --field=)'{--username,--password,--url,--notes,--field=}'[Add field]'
 85+                _lpass_complete_uniqenames
 86+                has_color=1
 87+                has_sync=1
 88+                has_interactive=1
 89+            ;;
 90+            edit)
 91+                _arguments : '(--name --username --password --url --notes --field=)'{--name,--username,--password,--url,--notes,--field=}'[Update field]'
 92+                _lpass_complete_uniqenames
 93+                has_color=1
 94+                has_sync=1
 95+                has_interactive=1
 96+            ;;
 97+            generate)
 98+                _arguments : \
 99+                  '(-c --clip)'{-c,--clip}'[Copy output to clipboard]' \
100+                  '--username=[USERNAME]' \
101+                  '--url=[URL]' \
102+                  '--no-symbols[Do not use symbols]'
103+                has_sync=1
104+            ;;
105+            status)
106+               _arguments : '(-q --quiet)'{-q,--quiet}'[Supress output to stdout]'
107+                has_color=1
108+            ;;
109+            sync)
110+                _arguments : '(-b --background)'{-b,--background}'[Run sync in background]'
111+                has_color=1
112+            ;;
113+            export)
114+                _arguments : '--fields=[Field list]'
115+                has_color=1
116+                has_sync=1
117+            ;;
118+            import)
119+              if ((CURRENT < 3)); then
120+                _files
121+              fi
122+            ;;
123+        esac
124+