diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2022-11-21 13:04:12 +0100 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2022-11-21 13:04:12 +0100 |
commit | 3e506474a816e0c30b8cf0f30afb0f7f5059d881 (patch) | |
tree | 31a526c3b3c7a5171dcf46be2fb1822726a658e7 | |
parent | a105b5a13eb56f94bfad0eb28f2e73eafd98b671 (diff) | |
download | alpine-conf-3e506474a816e0c30b8cf0f30afb0f7f5059d881.zip |
setup-apkrepos: make fastest/first/random options exclusive
Makes no sense to combine them
-rw-r--r-- | setup-apkrepos.in | 20 | ||||
-rwxr-xr-x | tests/setup_apkrepos_test | 8 |
2 files changed, 24 insertions, 4 deletions
diff --git a/setup-apkrepos.in b/setup-apkrepos.in index 5c6d49b..63b1600 100644 --- a/setup-apkrepos.in +++ b/setup-apkrepos.in @@ -142,7 +142,7 @@ edit_repositories() { usage() { cat <<-__EOF__ - usage: setup-apkrepos [-cfhr1] [REPO...] + usage: setup-apkrepos [-ch] [-f|-r|-1|REPO...] Setup apk repositories @@ -163,10 +163,22 @@ add_random=false while getopts "c1fhr" opt; do case $opt in c) community_prefix="";; - f) add_fastest=true;; - 1) add_first=true;; + f) add_fastest=true + if $add_first || $add_random; then + usage "1" >&2 + fi + ;; + 1) add_first=true + if $add_fastest || $add_random; then + usage "1" >&2 + fi + ;; h) usage 0;; - r) add_random=true;; + r) add_random=true + if $add_first || $add_fastest; then + usage "1" >&2 + fi + ;; '?') usage "1" >&2;; esac done diff --git a/tests/setup_apkrepos_test b/tests/setup_apkrepos_test index 26d9d76..ec0c349 100755 --- a/tests/setup_apkrepos_test +++ b/tests/setup_apkrepos_test @@ -3,6 +3,7 @@ . $(atf_get_srcdir)/test_env.sh init_tests \ setup_apkrepos_usage \ + setup_apkrepos_exclusive_opts \ setup_apkrepos_https \ setup_apkrepos_random \ setup_apkrepos_first @@ -11,6 +12,13 @@ setup_apkrepos_usage_body() { test_usage setup-apkrepos } +setup_apkrepos_exclusive_opts_body() { + init_env + atf_check -s exit:1 -e match:"usage" setup-apkrepos -r -f + atf_check -s exit:1 -e match:"usage" setup-apkrepos -r -1 + atf_check -s exit:1 -e match:"usage" setup-apkrepos -f -1 +} + setup_apkrepos_https_body() { init_env export MIRRORS="https://a.example.com http://b.example.com" |