diff options
author | Ulrich Müller <ulm@gentoo.org> | 2021-02-19 14:31:07 +0100 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2021-02-19 14:31:07 +0100 |
commit | 74aa11482d3ab7cdbe44b85027e5b8c20ce82bb4 (patch) | |
tree | 25fb7cd9cef8ee9decaeec2e8da22905eb383ae7 /modules | |
parent | Prefer realpath in configure check. (diff) | |
download | eselect-74aa11482d3ab7cdbe44b85027e5b8c20ce82bb4.tar.gz eselect-74aa11482d3ab7cdbe44b85027e5b8c20ce82bb4.tar.bz2 eselect-74aa11482d3ab7cdbe44b85027e5b8c20ce82bb4.zip |
news.eselect: Support "new" and "all" options in list action
* modules/news.eselect (do_list): Recognise "new" and "all"
options, bug 771075.
(describe_list_options): New function.
Bug: https://bugs.gentoo.org/771075
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/news.eselect | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/modules/news.eselect b/modules/news.eselect index f941a8c..5125431 100644 --- a/modules/news.eselect +++ b/modules/news.eselect @@ -1,5 +1,5 @@ # -*-eselect-*- vim: ft=eselect -# Copyright 2005-2020 Gentoo Authors +# Copyright 2005-2021 Gentoo Authors # Distributed under the terms of the GNU GPL version 2 or later inherit package-manager @@ -171,16 +171,30 @@ describe_list() { echo "List news items" } +describe_list_options() { + echo "new : List unread news items" + echo "all : List all news items (default)" +} + do_list() { - local item stat repo dir header line format title posted i=1 + local item stat repo dir header line format title posted unread i=0 n=0 local cols=${COLUMNS:-80} ifs_save=${IFS} local -a repos dirs + case $1 in + new) unread=1 ;; + all|"") ;; + *) write_warning_msg "Bad option: $1" ;; + esac + set -- $(find_items unread read) write_list_start "News items:" for item; do + (( i++ )) stat=${item%%/*}; item=${item#*/} repo=${item%%/*}; item=${item#*/} + [[ ! ${unread} || ${stat} = unread ]] || continue + (( n++ )) find_repo_dir "${repo}" title="(${item} - no title)" posted=${item:0:10} @@ -215,9 +229,8 @@ do_list() { else write_numbered_list_entry ${i} " ${line}" fi - (( i++ )) done - [[ $# -eq 0 ]] && ! is_output_mode brief \ + [[ ${n} -eq 0 ]] && ! is_output_mode brief \ && write_kv_list_entry "(none found)" "" } |