Forum Discussion

Former Member's avatar
Former Member
4 years ago

[16,17,20,37,38] Support for both versions in scripts

Hi,

Initial impression of the new version is great! The UI with grouping by category makes sense.
And I can't wait for the TouchID support. :)

Unfortunately the changed UI also breaks all existing scripts and https://direnv.net configurations.

Maybe a note to https://developer.1password.com/docs/cli/upgrade/ about supporting both versions in shell scripts?

With Bash e.g.:

```bash
OP_VERSION="$(op --version)"

if [[ "$OP_VERSION" == 1.* ]]; then
op get item ...
else
op item get ...
fi
```

Or this should be Posix compliant:

```sh
OP_VERSION="$(op --version)"

case "$OP_VERSION" in
1.*) op get item ...;;
*) op read op://...;;
esac
```

Cheers,
- Teemu


1Password Version: Not Provided
Extension Version: Not Provided
OS Version: macOS 12.1

12 Replies

  • 1P_Simon's avatar
    1P_Simon
    Icon for 1Password Team rank1Password Team

    Love it!

    You could even print a suggestion on stderr helping your colleagues remind to upgrade:

    ```bash
    OP_VERSION="$(op --version)"

    if [[ "$OP_VERSION" == 1.* ]]; then
    {
    echo We're migrating to 1Password CLI 2.0. Please upgrade your installation:
    echo " https://developer.1password.com/docs/cli/upgrade"
    } >&2
    op get item ...
    else
    op item get ...
    fi
    ```

  • Former Member's avatar
    Former Member

    Hi @r00t,

    Thank you for giving our beta of 1Password CLI 2.0 a spin!
    I can definitely see how adapting your scripts for both versions of the CLI can be really useful, during the transition period, so I'll take this idea up with my team.
    Naturally, after the official launch, 1Password CLI 1 will be deprecated, at some point, but we want to make sure we're not disrupting any of our users' workflows in this process, and your idea helps us achieve just that. :smile:
    If you have any other feedback for us, don't hesitate to reach out, we are here to listen and to help.
    Once again, thank you for trying out our beta!

    Horia