#!/usr/bin/env bash

case "${1}" in
    get)
        read REGISTRY
        case "${REGISTRY}" in
            ("registry-a.com") echo "{\"ServerURL\":\"${REGISTRY}\",\"Username\":\"foo\",\"Secret\":\"bar\"}" ;;
            ("registry-b.com") echo "{\"ServerURL\":\"${REGISTRY}\",\"Username\":\"<token>\",\"Secret\":\"fizzbuzz\"}" ;;
            ("registry-no-creds.com") echo "credentials not found in native keychain" && exit 1 ;;
            (*) echo "{}" ;;
        esac
        exit 0
    ;;
    store)
        read UNUSED
        exit 0
    ;;
    list)
        read UNUSED
        echo "{\"registry-a.com\":\"foo\"}"
        exit 0
    ;;
    *)
        echo "not implemented"
        exit 1
    ;;
esac
