[!windows] chmod 755 bin/op
[windows] unix2dos bin/op.cmd

# test onepassword template function
chezmoi execute-template '{{ (onepassword "ExampleLogin").uuid }}'
stdout '^wxcplh5udshnonkzg2n4qx262y$'

# test onepasswordDetailsFields template function
chezmoi execute-template '{{ (onepasswordDetailsFields "ExampleLogin").password.value }}'
stdout '^L8rm1JXJIE1b8YUDWq7h$'

-- bin/op --
#!/bin/sh

case "$*" in
"--version")
    echo 1.3.0
    ;;
"get item ExampleLogin")
    echo '{"uuid":"wxcplh5udshnonkzg2n4qx262y","templateUuid":"001","trashed":"N","createdAt":"2020-07-28T13:44:57Z","updatedAt":"2020-07-28T14:27:46Z","changerUuid":"VBDXOA4MPVHONK5IIJVKUQGLXM","itemVersion":2,"vaultUuid":"tscpxgi6s7c662jtqn3vmw4n5a","details":{"fields":[{"designation":"username","name":"username","type":"T","value":"exampleuser"},{"designation":"password","name":"password","type":"P","value":"L8rm1JXJIE1b8YUDWq7h"}],"notesPlain":"","passwordHistory":[],"sections":[]},"overview":{"URLs":[{"l":"website","u":"https://www.example.com/"}],"ainfo":"exampleuser","pbe":119.083926,"pgrng":true,"ps":100,"tags":[],"title":"ExampleLogin","url":"https://www.example.com/"}}'
    ;;
*)
    echo [ERROR] 2020/01/01 00:00:00 unknown command \"$*\" for \"op\"
    exit 1
esac
-- bin/op.cmd --
@echo off
IF "%*" == "--version" (
    echo 1.3.0
) ELSE IF "%*" == "get item ExampleLogin" (
    echo.{"uuid":"wxcplh5udshnonkzg2n4qx262y","templateUuid":"001","trashed":"N","createdAt":"2020-07-28T13:44:57Z","updatedAt":"2020-07-28T14:27:46Z","changerUuid":"VBDXOA4MPVHONK5IIJVKUQGLXM","itemVersion":2,"vaultUuid":"tscpxgi6s7c662jtqn3vmw4n5a","details":{"fields":[{"designation":"username","name":"username","type":"T","value":"exampleuser"},{"designation":"password","name":"password","type":"P","value":"L8rm1JXJIE1b8YUDWq7h"}],"notesPlain":"","passwordHistory":[],"sections":[]},"overview":{"URLs":[{"l":"website","u":"https://www.example.com/"}],"ainfo":"exampleuser","pbe":119.083926,"pgrng":true,"ps":100,"tags":[],"title":"ExampleLogin","url":"https://www.example.com/"}}
) ELSE (
    echo.[ERROR] 2020/01/01 00:00:00 unknown command "%*" for "op"
    exit /b 1
)
