#!/bin/bash

## Load action gets a first argument a DIRECTORY holding the necessary files.
##
##

if [ -z "$SERVICE_DATASTORE" ]; then
    echo "This script is meant to be run through 'compose' to work properly." >&2
    exit 1
fi

usage="$exname [-h|--help] KEYWORD"

KEYWORD=
while [ "$1" ]; do
    case "$1" in
        "--help"|"-h")
            print_usage
            exit 0
        ;;
        *)
            [ -z "$KEYWORD" ] && { KEYWORD=$1 ; shift ; continue ; }
            err "Unexpected argument '$1'."
            exit 1
        ;;
    esac
    shift
done


if [ -z "$KEYWORD" ]; then
    err "You must provide a keyword as first argument."
    print_usage
    exit 1
fi

. "$CHARM_PATH/lib/common"

## This can work only if ~/.pgpass is correctly created by init.

case "$KEYWORD" in
    url)
        ini get server ROOT_URL || true
        ;;
    name)
        echo gitea
        ;;
    *)
        err "Unknown keyword $KEYWORD."
        exit 1
        ;;
esac