Hello,
Couple years ago support for descriptions for alternatives was introduced. E.g.:
ALTERNATIVES_cc_DESCRIPTION="System-wide C compiler"
ALTERNATIVES_vi_DESCRIPTION="Default provider for the vi text editor"
in the bottom of alternatives.exlib. More alternatives need to start using this
but it's a start. If you run `eclectic` these descriptions are shown. If you
run `eclectic vi help` the vi alternative description is also shown.
If you run `eclectic vi` it is, however, not shown. That's dumb. Attached in
0001-Show-description-by-default-in-eclectic-alternative-.patch for ::arbor is
a solution to that. The normal default action is usage. Help prints the
description and then usage. So seems okay.
Additionally the desire to provide descriptions for alternative providers has
been discussed. Attached in
0001-Show-contents-of-_description-file-if-it-exists-in-e.patch for ::eclectic
and 0002-Add-alternatives_for_with_description-which-allows-s.patch for ::arbor
is a way to show provider descriptions in `eclectic ${alternative} list`
output.
To specify provider description has been added a new
`alternatives_for_with_descriptions` function which takes a fourth description
argument and puts it in
/etc/env.d/alternatives/${alternative}/${provider}/_description similar to how
importance is stored.
Does anybody have suggestions for a better name for
`alternatives_for_with_description`? Comments?
--
Bo Ørsted Andresen
>From 2deca8ffb90c1ac9f58236b79e65f32e0e756640 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bo=20=C3=98rsted=20Andresen?= <[email protected]>
Date: Wed, 13 Sep 2017 15:12:29 +0200
Subject: [PATCH 1/2] Show description by default in eclectic $alternative
output.
---
exlibs/alternatives.exlib | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/exlibs/alternatives.exlib b/exlibs/alternatives.exlib
index 42687615e..a4f89acb2 100644
--- a/exlibs/alternatives.exlib
+++ b/exlibs/alternatives.exlib
@@ -114,7 +114,7 @@ cleanup_old_alternatives_module() {
alternatives_pkg_postinst() {
illegal_in_global_scope
- local a alt alt_description provider module_version="20090908"
sanitized_alt
+ local a alt alt_description provider module_version="20170914"
sanitized_alt
for a in "${ALTERNATIVES_PROVIDED[@]}"; do
alt="${a%:*}"
provider="${a#*:}"
@@ -133,6 +133,7 @@ alternatives_pkg_postinst() {
DESCRIPTION="${alt_description}"
VERSION="${module_version}"
MAINTAINER="[email protected]"
+DEFAULT_ACTION="help"
ECLECTIC_MODULE_GROUP="Alternatives"
ALTERNATIVE="${alt}"
--
2.14.1
>From da088d44cf2edcf6506a4b6c1c94b4ec6fa2464c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bo=20=C3=98rsted=20Andresen?= <[email protected]>
Date: Wed, 13 Sep 2017 17:11:59 +0200
Subject: [PATCH] Show contents of _description file if it exists in eclectic
$alternative list
Change-Id: I8f6bd4da5720a1b618a0d7658a5521222d0821c7
---
libs/alternatives.bash.in | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/libs/alternatives.bash.in b/libs/alternatives.bash.in
index aafccf2..3200f3a 100644
--- a/libs/alternatives.bash.in
+++ b/libs/alternatives.bash.in
@@ -37,11 +37,19 @@ do_list() {
cur="$(get_current_provider)"
if [[ -n "${providers[@]}" ]] ; then
+ local p desc description
+ for (( n = 1 ; n < ${#providers[@]} + 1 ; ++n )) ; do
+ [[ ${cur} == "${providers[n-1]}" ]] && \
+ providers[n-1]="${providers[n-1]} $(highlight '*')"
+ providers[n-1]="[${n}] ${providers[n-1]}"
+ done
for (( n = 0 ; n < ${#providers[@]} ; ++n )) ; do
- [[ ${cur} == "${providers[${n}]}" ]] && \
- providers[${n}]="${providers[${n}]} $(highlight '*')"
+ p=${providers[${n}]#* }
+ desc="${ALTERNATIVESDIR}/${ALTERNATIVE}/${p%% *}/_description"
+ description=
+ [[ -f ${desc} ]] && description=$(<"${desc}")
+ write_kv_list_entry "${providers[n]}" "${description}"
done
- write_numbered_list "${providers[@]}"
else
write_kv_list_entry "(none found)" ""
fi
--
2.14.1
>From 18471f61b81b03924992d33d2b0b2ecdd9182756 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bo=20=C3=98rsted=20Andresen?= <[email protected]>
Date: Thu, 14 Sep 2017 16:33:56 +0200
Subject: [PATCH 2/2] Add alternatives_for_with_description() which allows
setting a description for each provider.
Change-Id: I4f06dd0147cf57a95e914976485684eef9164e53
---
exlibs/alternatives.exlib | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/exlibs/alternatives.exlib b/exlibs/alternatives.exlib
index a4f89acb2..80dbacb88 100644
--- a/exlibs/alternatives.exlib
+++ b/exlibs/alternatives.exlib
@@ -16,6 +16,20 @@ DEPENDENCIES="
install:
app-admin/eclectic[>=2.0.13]"
+# alternatives_for_with_description alternative provider importance
description source target [ source target [...]]
+alternatives_for_with_description() {
+ echo alternatives_for_with_description "${@}"
+
+ (( $# >= 6 )) && (( ($#-4)%2 == 0)) || die "${FUNCNAME} requires exactly
4+N*2 arguments where N>=1"
+
+ local alternative=${1} provider=${2} importance=${3} description=${4}
+ shift 4
+
+ alternatives_for "${alternative}" "${provider}" "${importance}" "${@}"
+
+ [[ -n ${description} ]] && echo "${description}" >
"${IMAGE}${ALTERNATIVES_DIR}/${alternative}/${provider}/_description"
+}
+
# alternatives_for alternative provider importance source target [ source
target [...]]
alternatives_for() {
illegal_in_global_scope
--
2.14.1
_______________________________________________
Exherbo-dev mailing list
[email protected]
http://lists.exherbo.org/mailman/listinfo/exherbo-dev