chore: import.sh: read config from env

This commit is contained in:
Paul Pan 2024-01-05 15:03:04 +08:00
parent 99d8bd6b80
commit 2fe58482db
Signed by: Paul
GPG Key ID: D639BDF5BA578AF4

View File

@ -3,22 +3,37 @@
WORKSPACE=$(cd "$(dirname "$0")"/.. && pwd)
. "$WORKSPACE"/scripts/common.sh
read -p "Enter HTTP API Endpoint: " -r endpoint
if [ -z "$endpoint" ]; then
if [ -z "$WOJ_ENDPOINT" ]; then
read -p "Enter HTTP API Endpoint: " -r endpoint
if [ -z "$endpoint" ]; then
log_error "[-] HTTP API Endpoint cannot be empty"
exit 1
fi
else
endpoint="$WOJ_ENDPOINT"
log_info "[*] Using HTTP API Endpoint: $endpoint"
fi
read -p "Enter Token: " -r token
if [ -z "$token" ]; then
if [ -z "$WOJ_TOKEN" ]; then
read -p "Enter Token: " -r token
if [ -z "$token" ]; then
log_error "[-] Token cannot be empty"
exit 1
fi
else
token="$WOJ_TOKEN"
log_info "[*] Using Token: $token"
fi
read -p "Enter Directory: " -r directory
if [ ! -d "$directory" ]; then
if [ -z "$WOJ_DIR" ]; then
read -p "Enter Directory: " -r directory
if [ ! -d "$directory" ]; then
log_error "[-] Not a Directory"
exit 1
fi
else
directory="$WOJ_DIR"
log_info "[*] Using Directory: $directory"
fi
for problem in "$directory/"*; do