split out the lib

This commit is contained in:
Earl Warren 2023-10-11 18:05:11 +02:00
parent 95aee3f580
commit 5f8f262472
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
5 changed files with 508 additions and 58 deletions

View file

@ -2,46 +2,7 @@
# SPDX-License-Identifier: MIT
SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
VERBOSE=false
DEBUG=false
: ${EXIT_ON_ERROR:=true}
function debug() {
DEBUG=true
set -x
PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: '
}
function verbose() {
VERBOSE=true
}
function log() {
echo "$@" >&2
}
function log_error() {
log "$@"
}
function log_verbose() {
if $VERBOSE ; then
log "$@"
fi
}
function log_info() {
log "$@"
}
function fatal_error() {
log_error "$@"
if $EXIT_ON_ERROR ; then
exit 1
else
return 1
fi
}
source $SELF_DIR/../cascading-pr-lib.sh
function push_self() {
local host_port=$1
@ -50,18 +11,16 @@ function push_self() {
}
function run() {
local host_port=$1 url=$2 token=$3
push_self $host_port
push_self ${options[host_port]}
echo do something
}
function main() {
local command=run
local host_port=$(cat forgejo-ip):3000
local url=http://$host_port
local token=$(cat forgejo-token)
options[host_port]=$(cat forgejo-ip):3000
options[url]=http://$host_port
options[token]=$(cat forgejo-token)
while true; do
case "$1" in
@ -75,18 +34,18 @@ function main() {
;;
--host_port)
shift
host_port=$1
options[host_port]=$1
;;
--url)
shift
url=$1
options[url]=$1
;;
--token)
shift
token=$1
options[token]=$1
;;
*)
"${1:-run}" "$host_port" "$url" "$token"
"${1:-run}"
return 0
;;
esac