aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/cpt-build20
-rwxr-xr-xsrc/cpt-install16
-rwxr-xr-xsrc/cpt-remove11
-rwxr-xr-xsrc/cpt-search24
-rwxr-xr-xsrc/cpt-update15
5 files changed, 51 insertions, 35 deletions
diff --git a/src/cpt-build b/src/cpt-build
index a143b67..0a4326b 100755
--- a/src/cpt-build
+++ b/src/cpt-build
@@ -4,11 +4,21 @@
# shellcheck disable=1091
if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi
-case "$1" in
- '') set -- "${PWD##*/}"; export CPT_PATH=${PWD%/*}:$CPT_PATH ;;
- --help|-h) out "usage: ${0##*/} [pkg...]"; exit 1 ;;
- --version|-v) version ;;
-esac
+eval set -- "$(getopt -l no-prompt,version,help -- yvh "$@")"
+while :; do
+ case "$1" in
+ --help|-h)
+ out "usage: ${0##*/} [pkg...]" "" \
+ " Options:" \
+ " -y --no-prompt Do not prompt for confirmation" \
+ exit 1 ;;
+ --version|-v) version ;;
+ --no-prompt|-y) export CPT_PROMPT=0; shift ;;
+ --) shift; break ;;
+ esac
+done
+
+[ "$1" ] || set -- "${PWD##*/}"; export CPT_PATH=${PWD%/*}:$CPT_PATH
create_cache
diff --git a/src/cpt-install b/src/cpt-install
index d971974..548ba0c 100755
--- a/src/cpt-install
+++ b/src/cpt-install
@@ -4,21 +4,21 @@
# shellcheck disable=1091
if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi
-while [ "$1" ]; do
+eval set -- "$(getopt -l help,version,force,root: -- fhv "$@")"
+
+while :; do
case "$1" in
--help|-h)
out "usage: ${0##*/} [options] [pkg...]" "" \
" Options:" \
- " --force Force installation" \
+ " -f --force Force installation" \
" --root [rootdir] Use an alternate root directory" ""
exit 1
;;
- --version|-v) version ;;
- --force) export CPT_FORCE=1 ;;
- --root) export CPT_ROOT=$2; shift 2 ;;
- --) break ;;
- -*) die "Unknown argument '$1'" ;;
- *) break ;;
+ --version|-v) version ;;
+ -f|--force) export CPT_FORCE=1; shift ;;
+ --root) export CPT_ROOT=$2; shift 2 ;;
+ --) shift; break ;;
esac
done
diff --git a/src/cpt-remove b/src/cpt-remove
index b36e403..6c4bc82 100755
--- a/src/cpt-remove
+++ b/src/cpt-remove
@@ -4,7 +4,8 @@
# shellcheck disable=1091
if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi
-while [ "$1" ]; do
+eval set -- "$(getopt -l help,version,force,root: -- fhv "$@")"
+while :; do
case "$1" in
--help|-h)
out "usage: ${0##*/} [options] [pkg...]" "" \
@@ -13,12 +14,10 @@ while [ "$1" ]; do
" --root [rootdir] Use an alternate root directory" ""
exit 1
;;
- --version|-v) version ;;
- --force) export CPT_FORCE=1; shift ;;
+ -v|--version) version ;;
+ -f|--force) export CPT_FORCE=1; shift ;;
--root) export CPT_ROOT=$2; shift 2 ;;
- --) break ;;
- -*) die "Unknown argument '$1'" ;;
- *) break ;;
+ --) shift; break ;;
esac
done
diff --git a/src/cpt-search b/src/cpt-search
index 47faaf7..7eaffb9 100755
--- a/src/cpt-search
+++ b/src/cpt-search
@@ -8,15 +8,19 @@ if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi
# in order to only find the first instance of a package.
all=1
-case "$1" in
- --help|-h|'')
- out "usage: ${0##*/} [--single] [pkg...]" "" \
- " Options:" \
- " --single Only show the first instance of a package" ""
- exit 0
- ;;
- --version|-v) version ;;
- --single) unset all; shift ;;
-esac
+eval set -- "$(getopt -l single,version,help -- shv "$@")"
+while :; do
+ case "$1" in
+ --help|-h|'')
+ out "usage: ${0##*/} [--single] [pkg...]" "" \
+ " Options:" \
+ " -s --single Only show the first instance of a package" ""
+ exit 0
+ ;;
+ --version|-v) version ;;
+ --single|-s) unset all; shift ;;
+ --) shift; break ;;
+ esac
+done
for pkg; do pkg_find "$pkg" "${all:+all}"; done
diff --git a/src/cpt-update b/src/cpt-update
index 417b0e3..643da5c 100755
--- a/src/cpt-update
+++ b/src/cpt-update
@@ -4,21 +4,24 @@
# shellcheck disable=1091
if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi
-while [ "$1" ]; do
+eval set -- "$(getopt -l no-fetch,download,root:,help,version,no-prompt -- yndhv "$@")"
+while :; do
case "$1" in
--help|-h)
out "usage: ${0##*/} [options]" "" \
" Options:" \
" -d --download Only download updatable packages" \
- " --no-fetch Do not refresh the repositories" \
+ " -n --no-fetch Do not refresh the repositories" \
+ " -y --no-prompt Do not prompt for confirmation" \
" --root [rootdir] Use an alternate root directory" ""
exit 1
;;
--version|-v) version ;;
- --no-fetch) export CPT_FETCH=0; shift ;;
- --root) export CPT_ROOT=$2; shift 2 ;;
- --download|-d) export download_only=1; shift ;;
- *) die "Unknown option '$1'" ;;
+ -d|--download) export download_only=1; shift ;;
+ -n|--no-fetch) export CPT_FETCH=0; shift ;;
+ -y|--no-prompt) CPT_PROMPT=0; shift ;;
+ --root) export CPT_ROOT=$2; shift 2 ;;
+ --) shift; break ;;
esac
done