From dbadfa0810c0be346b98c02cc802c33fa43bee11 Mon Sep 17 00:00:00 2001 From: Adam Pike Date: Sat, 26 Mar 2022 15:11:04 +0100 Subject: refactor(1password): support CLI 2 and soft-deprecate CLI 1 (#10787) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change still supports CLI 1, but shows a deprecation warning on the first run of `opswd`. Support for CLI 1 shall be removed in the near future. Closes #10787 Co-authored-by: Marc Cornellà --- plugins/1password/_opswd | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'plugins/1password/_opswd') diff --git a/plugins/1password/_opswd b/plugins/1password/_opswd index b92bf8fc8..dbc094f87 100644 --- a/plugins/1password/_opswd +++ b/plugins/1password/_opswd @@ -2,8 +2,18 @@ function _opswd() { local -a services - services=("${(@f)$(op list items --categories Login 2>/dev/null | op get item - --fields title 2>/dev/null)}") + services=("${(@f)$(op item list --categories Login --cache 2>/dev/null | awk 'NR != 1 { print $2 }')}") [[ -z "$services" ]] || compadd -a -- services } +# TODO: 2022-03-26: Remove support for op CLI 1 +autoload -Uz is-at-least +is-at-least 2.0.0 $(op --version) || { + function _opswd() { + local -a services + services=("${(@f)$(op list items --categories Login 2>/dev/null | op get item - --fields title 2>/dev/null)}") + [[ -z "$services" ]] || compadd -a -- services + } +} + _opswd "$@" -- cgit v1.2.3-70-g09d2