#!/bin/bash
# -*- mode: sh; tab-width: 8; encoding: utf-8-unix -*-

prog=`basename $0 .bash`
PREFIX=/usr/local
ROLE=gpgkey
root=KeeC
DEBUG=1

. /usr/local/bin/usr_local_tput.bash
. /usr/local/bin/gridfire.rc
EXE=/var/local/bin/keepassxc.bash

# not -k not -p
[[ "$*" =~ "--pw-stdin" ]] || [[ $RARGS =~ "--pw-stdin" ]] || RARGS="--pw-stdin $RARGS"
# not =''
[[ "$*" =~ "--keyfile" ]] || [[ $RARGS =~ "--keyfile" ]] || RARGS="--keyfile '' $RARGS"

DEBUG=1
DEBUG $EXE $RARGS "$@" >> /tmp/${root}$$.log
$EXE $RARGS "$@" 2>/tmp/${root}$$.err >/tmp/${root}$$.log
retval=$?
if [ $retval  -eq 0 ] ; then
    INFO see /tmp/${root}$$.log
else
    WARN see /tmp/${root}$$.err
    cat /tmp/${root}$$.err
fi
exit $retval

