From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 966161382C5 for ; Fri, 19 Feb 2021 13:33:15 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B639CE0D7D; Fri, 19 Feb 2021 13:33:14 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 9F7D7E0D7D for ; Fri, 19 Feb 2021 13:33:14 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A02D3340F7B for ; Fri, 19 Feb 2021 13:33:13 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 284664E4 for ; Fri, 19 Feb 2021 13:33:12 +0000 (UTC) From: "Ulrich Müller" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Ulrich Müller" Message-ID: <1613741467.74aa11482d3ab7cdbe44b85027e5b8c20ce82bb4.ulm@gentoo> Subject: [gentoo-commits] proj/eselect:master commit in: modules/, / X-VCS-Repository: proj/eselect X-VCS-Files: ChangeLog modules/news.eselect X-VCS-Directories: modules/ / X-VCS-Committer: ulm X-VCS-Committer-Name: Ulrich Müller X-VCS-Revision: 74aa11482d3ab7cdbe44b85027e5b8c20ce82bb4 X-VCS-Branch: master Date: Fri, 19 Feb 2021 13:33:12 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 2db83111-fb54-414a-a9a8-250a12fcfc4d X-Archives-Hash: 3812fdbbf6c97d8dbfe84a1a3e9f57e8 commit: 74aa11482d3ab7cdbe44b85027e5b8c20ce82bb4 Author: Ulrich Müller gentoo org> AuthorDate: Fri Feb 19 13:31:07 2021 +0000 Commit: Ulrich Müller gentoo 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 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 + + * modules/news.eselect (do_list): Recognise "new" and "all" + options, bug 771075. + (describe_list_options): New function. + 2020-12-18 Ulrich Müller * 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)" "" }