From 2148b2e06b27bfabd901b168ea13acf3929f819d Mon Sep 17 00:00:00 2001 From: Joseph Werle Date: Sat, 28 May 2022 12:15:59 +0200 Subject: [PATCH] refactor(): clean up useless versions in subcommands --- bpkg.json | 4 ++-- bpkg.sh | 2 +- lib/env/env.sh | 24 +++++++++++++----------- lib/install/install.sh | 4 ---- lib/list/list.sh | 9 +-------- lib/show/show.sh | 11 ++--------- lib/term/term.sh | 8 -------- lib/update/update.sh | 6 ------ 8 files changed, 19 insertions(+), 49 deletions(-) diff --git a/bpkg.json b/bpkg.json index eeb7af3..3d03289 100644 --- a/bpkg.json +++ b/bpkg.json @@ -1,12 +1,12 @@ { "name": "bpkg", - "version": "1.0.25", + "version": "1.1.0", "description": "Lightweight bash package manager", "global": true, "repo": "bpkg/bpkg", "install": "bash setup.sh", "commands": { "lint": "command shellcheck **/*.sh", - "list-sources": "echo ${BPKG_SCRIPT_SOURCES[@]} | sed 's/ /\n/g'" + "list-sources": "echo ${BPKG_PACKAGE_SOURCES[@]} | sed 's/ /\n/g'" } } diff --git a/bpkg.sh b/bpkg.sh index 78d3add..e61b30b 100755 --- a/bpkg.sh +++ b/bpkg.sh @@ -7,7 +7,7 @@ if [[ ${BASH_SOURCE[0]} != "$0" ]]; then fi ## bpkg version -VERSION="1.0.25" +VERSION="1.1.0" ## output error to stderr error () { diff --git a/lib/env/env.sh b/lib/env/env.sh index 3f4df86..0754134 100755 --- a/lib/env/env.sh +++ b/lib/env/env.sh @@ -18,11 +18,14 @@ else source "$(which bpkg-realpath)" fi +# List of bash source files +declare -a BPKG_PACKAGE_SOURCES=() + # Include config rc file if found -BPKG_USER_CONFIG_FILE="$HOME/.bpkgrc" +declare BPKG_USER_CONFIG_FILE="$HOME/.bpkgrc" # Include config rc file if found -BPKG_LOCAL_CONFIG_FILE="$(pwd)/.bpkgrc" +declare BPKG_LOCAL_CONFIG_FILE="$(pwd)/.bpkgrc" ## meta export BPKG_DATE="$(date)" @@ -49,7 +52,7 @@ export BPKG_PACKAGE_PATH="$(bpkg_package_path)" export BPKG_PACKAGE_ROOT="$(bpkg_realpath "$(dirname "$BPKG_PACKAGE_PATH")")" export BPKG_PACKAGE_DEPS="$BPKG_PACKAGE_ROOT/deps" export BPKG_PACKAGE_VERSION="$(bpkg_package version 2>/dev/null)" -export BPKG_PACKAGE_DESCRIPTION="$(bpkg_package description 2>/dev/null)" +export BPKG_PACKAGE_DEPACKAGEION="$(bpkg_package description 2>/dev/null)" export BPKG_PACKAGE_DEFAULT_USER="${BPKG_PACKAGE_DEFAULT_USER:-bpkg}" ## remote @@ -59,11 +62,10 @@ export BPKG_REMOTES export BPKG_REMOTE_RAW_PATH if test -f "$BPKG_PACKAGE_PATH"; then - declare -a BPKG_SCRIPT_SOURCES=() - BPKG_SCRIPT_SOURCES+=($(find "$BPKG_SCRIPT_ROOT" -name '*.sh' 2>/dev/null)) - BPKG_SCRIPT_SOURCES+=($(find "$BPKG_SCRIPT_ROOT" -name '*.zsh' 2>/dev/null)) - BPKG_SCRIPT_SOURCES+=($(find "$BPKG_SCRIPT_ROOT" -name '*.bash' 2>/dev/null)) - export BPKG_SCRIPT_SOURCES + BPKG_PACKAGE_SOURCES+=($(find "$BPKG_PACKAGE_ROOT" -name '*.sh' 2>/dev/null)) + BPKG_PACKAGE_SOURCES+=($(find "$BPKG_PACKAGE_ROOT" -name '*.zsh' 2>/dev/null)) + BPKG_PACKAGE_SOURCES+=($(find "$BPKG_PACKAGE_ROOT" -name '*.bash' 2>/dev/null)) + export BPKG_PACKAGE_SOURCES fi if test -d "$BPKG_PACKAGE_DEPS/bin"; then @@ -81,10 +83,10 @@ example: $ bpkg-env BPKG_PACKAGE* BPKG_PACKAGE_DEPS="deps" BPKG_PACKAGE_NAME="bpkg" - BPKG_PACKAGE_DESCRIPTION="Lightweight bash package manager" + BPKG_PACKAGE_DEPACKAGEION="Lightweight bash package manager" BPKG_PACKAGE_REPO="bpkg/bpkg" BPKG_PACKAGE_USER="bpkg" - BPKG_PACKAGE_VERSION="1.0.7" + BPKG_PACKAGE_VERSION="1.1.0" USAGE } @@ -117,7 +119,7 @@ bpkg_env () { { printenv - echo BPKG_SCRIPT_SOURCES=\""${BPKG_SCRIPT_SOURCES[*]}"\" + echo BPKG_PACKAGE_SOURCES=\""${BPKG_PACKAGE_SOURCES[*]}"\" } | \ grep '^\s*BPKG_' | \ sed 's/^\s*//g' | \ diff --git a/lib/install/install.sh b/lib/install/install.sh index 01287ab..017db6c 100755 --- a/lib/install/install.sh +++ b/lib/install/install.sh @@ -258,8 +258,6 @@ bpkg_install () { ## 1: the package was not found on the remote ## 2: a fatal error occurred bpkg_install_from_remote () { - local cwd - local pkg=$1 local remote=$2 local git_remote=$3 @@ -282,8 +280,6 @@ bpkg_install_from_remote () { declare -a scripts=() declare -a files=() - cwd=$(pwd) - ## get version if available { OLDIFS="$IFS" diff --git a/lib/list/list.sh b/lib/list/list.sh index 45cd2f3..a3f33e2 100755 --- a/lib/list/list.sh +++ b/lib/list/list.sh @@ -1,7 +1,5 @@ #!/usr/bin/env bash -VERSION="0.0.1" - if ! type -f bpkg-utils &>/dev/null; then echo "error: bpkg-utils not found, aborting" exit 1 @@ -13,13 +11,12 @@ fi bpkg_initrc usage () { - echo "bpkg-list [-h|--help] [-V|--version] [-d|--details]" + echo "bpkg-list [-h|--help] [-d|--details]" echo echo "List all known bash packages from the repo. You first must run \`bpkg update' to sync the repo locally." echo "Options:" echo " --help|-h Print this help dialogue" - echo " --version|-V Print version and exit" echo " --details|-d More verbose output" } @@ -27,10 +24,6 @@ bpkg_list () { local verbose=0 for opt in "${@}"; do case "$opt" in - -V|--version) - echo "${VERSION}" - return 0 - ;; -h|--help) usage return 0 diff --git a/lib/show/show.sh b/lib/show/show.sh index 095c277..1b223b0 100755 --- a/lib/show/show.sh +++ b/lib/show/show.sh @@ -1,7 +1,5 @@ #!/usr/bin/env bash -VERSION="0.1.0" - if ! type -f bpkg-utils &>/dev/null; then echo "error: bpkg-utils not found, aborting" exit 1 @@ -27,7 +25,7 @@ usage () { echo "$mesg" echo fi - echo "bpkg-show [-Vh]" + echo "bpkg-show [-h|--help]" echo "bpkg-show " echo "bpkg-show readme " echo "bpkg-show sources " @@ -40,8 +38,7 @@ usage () { echo " order. This option suppresses other output and prints executable bash." echo echo "Options:" - echo " --help|-h Print this help dialogue" - echo " --version|-V Print version and exit" + echo " -h,--help Print this help dialogue" } show_package () { @@ -137,10 +134,6 @@ bpkg_show () { local pkg="" for opt in "$@"; do case "$opt" in - -V|--version) - echo "${VERSION}" - return 0 - ;; -h|--help) usage return 0 diff --git a/lib/term/term.sh b/lib/term/term.sh index ae00397..abbe370 100755 --- a/lib/term/term.sh +++ b/lib/term/term.sh @@ -1,8 +1,5 @@ #!/usr/bin/env bash -## version -VERSION="0.0.1" - ## coords (( _x=0 )) (( _y=0 )) @@ -183,11 +180,6 @@ term () { case "${arg}" in ## flags - -V|--version) - echo "${VERSION}" - return 0 - ;; - -h|--help) usage diff --git a/lib/update/update.sh b/lib/update/update.sh index 8644afe..18ae4dd 100755 --- a/lib/update/update.sh +++ b/lib/update/update.sh @@ -1,7 +1,5 @@ #!/usr/bin/env bash -VERSION="0.0.1" - if ! type -f bpkg-utils &>/dev/null; then echo "error: bpkg-utils not found, aborting" exit 1 @@ -49,10 +47,6 @@ bpkg_update_remote() { bpkg_update () { for opt in "${@}"; do case "$opt" in - -V|--version) - echo "${VERSION}" - return 0 - ;; -h|--help) usage return 0