commit: 74aa11482d3ab7cdbe44b85027e5b8c20ce82bb4 Author: Ulrich Müller <ulm <AT> gentoo <DOT> org> AuthorDate: Fri Feb 19 13:31:07 2021 +0000 Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org> CommitDate: Fri Feb 19 13:31:07 2021 +0000 URL: https://gitweb.gentoo.org/proj/eselect.git/commit/?id=74aa1148
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 <AT> gentoo.org> ChangeLog | 6 ++++++ modules/news.eselect | 21 +++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 90109e8..dfdfe47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2021-02-17 Ulrich Müller <[email protected]> + + * modules/news.eselect (do_list): Recognise "new" and "all" + options, bug 771075. + (describe_list_options): New function. + 2020-12-18 Ulrich Müller <[email protected]> * configure.ac (REALPATH, READLINK): Prefer realpath to readlink, 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)" "" }
