aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/cpt-build26
-rwxr-xr-xsrc/cpt-install31
-rwxr-xr-xsrc/cpt-remove32
-rwxr-xr-xsrc/cpt-search29
-rwxr-xr-xsrc/cpt-update36
5 files changed, 71 insertions, 83 deletions
diff --git a/src/cpt-build b/src/cpt-build
index b4c9dd9..d014f28 100755
--- a/src/cpt-build
+++ b/src/cpt-build
@@ -4,19 +4,19 @@
# shellcheck disable=1091
if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi
-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
+parser_definition() {
+ setup REST -- "usage: ${0##*/} [pkg...]"
+ msg -- '' 'Options:'
+ flag CPT_PROMPT -y --no-prompt on:0 -- "Do not prompt for confirmation"
+ disp :usage -h --help -- "Show this help message"
+ disp :version -v --version -- "Print version information"
+}
+
+eval "$(getoptions parser_definition parse "$0")"
+eval "$(getoptions_help parser_definition usage "$0")"
+
+parse "$@"
+eval set -- "$REST"
[ "$1" ] || set -- "${PWD##*/}"; export CPT_PATH=${PWD%/*}:$CPT_PATH
diff --git a/src/cpt-install b/src/cpt-install
index 548ba0c..0ee6816 100755
--- a/src/cpt-install
+++ b/src/cpt-install
@@ -4,23 +4,20 @@
# shellcheck disable=1091
if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi
-eval set -- "$(getopt -l help,version,force,root: -- fhv "$@")"
-
-while :; do
- case "$1" in
- --help|-h)
- out "usage: ${0##*/} [options] [pkg...]" "" \
- " Options:" \
- " -f --force Force installation" \
- " --root [rootdir] Use an alternate root directory" ""
- exit 1
- ;;
- --version|-v) version ;;
- -f|--force) export CPT_FORCE=1; shift ;;
- --root) export CPT_ROOT=$2; shift 2 ;;
- --) shift; break ;;
- esac
-done
+parser_definition() {
+ setup REST -- "usage: ${0##*/} [pkg...]"
+ msg -- '' 'Options:'
+ flag CPT_FORCE -f --force -- "Force installation"
+ param CPT_ROOT --root -- "Use an alternate root directory"
+ disp :usage -h --help -- "Show this help message"
+ disp :version -v --version -- "Print version information"
+}
+
+eval "$(getoptions parser_definition parse "$0")"
+eval "$(getoptions_help parser_definition usage "$0")"
+
+parse "$@"
+eval set -- "$REST"
[ "$1" ] || set -- "${PWD##*/}"; export CPT_PATH=${PWD%/*}:$CPT_PATH
diff --git a/src/cpt-remove b/src/cpt-remove
index 6c4bc82..7f3e64e 100755
--- a/src/cpt-remove
+++ b/src/cpt-remove
@@ -4,22 +4,20 @@
# shellcheck disable=1091
if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi
-eval set -- "$(getopt -l help,version,force,root: -- fhv "$@")"
-while :; do
- case "$1" in
- --help|-h)
- out "usage: ${0##*/} [options] [pkg...]" "" \
- " Options:" \
- " --force Force Removal" \
- " --root [rootdir] Use an alternate root directory" ""
- exit 1
- ;;
- -v|--version) version ;;
- -f|--force) export CPT_FORCE=1; shift ;;
- --root) export CPT_ROOT=$2; shift 2 ;;
- --) shift; break ;;
- esac
-done
+parser_definition() {
+ setup REST -- "usage: ${0##*/} [pkg...]"
+ msg -- '' 'Options:'
+ flag CPT_FORCE -f --force -- "Force removal"
+ param CPT_ROOT --root -- "Use an alternate root directory"
+ disp :usage -h --help -- "Show this help message"
+ disp :version -v --version -- "Print version information"
+}
+
+eval "$(getoptions parser_definition parse "$0")"
+eval "$(getoptions_help parser_definition usage "$0")"
+
+parse "$@"
+eval set -- "$REST"
[ "$1" ] || set -- "${PWD##*/}"; export CPT_PATH=${PWD%/*}:$CPT_PATH
@@ -28,5 +26,7 @@ done
exit $?
}
+create_cache
+
pkg_order "$@"
for pkg in $redro; do pkg_remove "$pkg" "${CPT_FORCE:-check}"; done
diff --git a/src/cpt-search b/src/cpt-search
index 7eaffb9..cc37d9a 100755
--- a/src/cpt-search
+++ b/src/cpt-search
@@ -4,23 +4,18 @@
# shellcheck disable=1091
if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi
-# By default we are showing all instances of a package. This value can be unset
-# in order to only find the first instance of a package.
-all=1
+parser_definition() {
+ setup REST -- "usage: ${0##*/} [pkg...]"
+ msg -- '' 'Options:'
+ flag all -s --single init:=1 on:'' -- "Only show the first instance of a package"
+ disp :usage -h --help -- "Show this help message"
+ disp :version -v --version -- "Print version information"
+}
-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
+eval "$(getoptions parser_definition parse "$0")"
+eval "$(getoptions_help parser_definition usage "$0")"
+
+parse "$@"
+eval set -- "$REST"
for pkg; do pkg_find "$pkg" "${all:+all}"; done
diff --git a/src/cpt-update b/src/cpt-update
index 643da5c..415353b 100755
--- a/src/cpt-update
+++ b/src/cpt-update
@@ -4,26 +4,22 @@
# shellcheck disable=1091
if command -v cpt-lib >/dev/null; then . cpt-lib; else . ./cpt-lib; fi
-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" \
- " -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 ;;
- -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
+parser_definition() {
+ setup REST -- "usage: ${0##*/} [options]"
+ msg -- '' 'Options:'
+ flag download_only -d --download -- "Only download updatable packages"
+ flag CPT_FETCH -n --no-fetch on:0 -- "Do not refresh the repositories"
+ flag CPT_PROMPT -y --no-prompt on:0 -- "Do not prompt for confirmation"
+ param CPT_ROOT --root -- "Use an alternate root directory"
+ disp :usage -h --help
+ disp :version -v --version
+}
+
+eval "$(getoptions parser_definition parse "$0")"
+eval "$(getoptions_help parser_definition usage "$0")"
+
+parse "$@"
+eval set -- "$REST"
create_cache