#!/usr/bin/env bash # # Tests run: # # bash -n cwget.sh # ./cwget.sh help # ./cwget.sh update --refresh # ./cwget.sh search rgfw # ./cwget.sh info rgfw # ./cwget.sh path rgfw # ./cwget.sh install rgfw --dry-run --dir ./external-test # ./cwget.sh --offline search rgfw # SCRIPT_NAME="$(basename "$0")" DEFAULT_SOURCE_URL="https://cwget.awwtools.com/" DEFAULT_CACHE_TTL="20m" base_dir_override="" cache_ttl_override="" cache_dir_override="" source_url_override="" refresh=0 offline=0 json_output=0 quiet=0 verbose=0 EXIT_GENERIC=1 EXIT_USAGE=2 EXIT_NETWORK=3 EXIT_CACHE=4 EXIT_NOT_FOUND=5 EXIT_CONFLICT=6 log() { if [ "$quiet" -eq 0 ]; then printf '%s\n' "$*" fi } vlog() { if [ "$verbose" -eq 1 ] && [ "$quiet" -eq 0 ]; then printf '%s\n' "$*" fi } warn() { if [ "$quiet" -eq 0 ]; then printf 'warning: %s\n' "$*" >&2 fi } die() { local msg="$1" local code="${2:-$EXIT_GENERIC}" printf 'error: %s\n' "$msg" >&2 exit "$code" } print_usage() { cat < [args] Global options: --base-dir Override base install directory --cache-ttl