aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--man/news-tng.eselect.55
-rw-r--r--modules/news-tng.eselect53
3 files changed, 39 insertions, 20 deletions
diff --git a/NEWS b/NEWS
index 3edba3f..38bb0c5 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ trunk:
- Allow setting system-wide default dictionary.
- Treat 'help' and 'version' options as if they were actions.
- Modules for the EDITOR, VISUAL, and PAGER environment variables.
+ - Module news-tng.eselect for reading Gentoo ('GLEP 42') news.
1.0.12:
Bug fixes:
diff --git a/man/news-tng.eselect.5 b/man/news-tng.eselect.5
index 64f65c4..24a0231 100644
--- a/man/news-tng.eselect.5
+++ b/man/news-tng.eselect.5
@@ -12,6 +12,7 @@ news-tng.eselect \- Yet another GLEP 42 news module for Gentoo's eselect
.B eselect news-tng list
.br
.B eselect news-tng read
+.RB [ \-\-raw ]
.RI [ item ...]
.br
.B eselect news-tng unread
@@ -39,6 +40,7 @@ News items:
[3] 2009-04-06 (read) Migration to X.org Server 1.5
.SH ACTION: READ
.B eselect news-tng read
+.RB [ \-\-raw ]
.RI [ item ...]
.br
Read news item(s), selected by their
@@ -51,6 +53,9 @@ and
.B all
select all unread items or all items, respectively.
Default is to read all unread news, if no item is specified.
+With option
+.BR \-\-raw ,
+output the item in raw format.
.SH ACTION: UNREAD
.B eselect news-tng unread
.RI [ item ...]
diff --git a/modules/news-tng.eselect b/modules/news-tng.eselect
index 51b3e7c..89a66a5 100644
--- a/modules/news-tng.eselect
+++ b/modules/news-tng.eselect
@@ -41,14 +41,17 @@ write_item_list() {
[[ ${item%%/*} = ${repo} ]] && update="${update} ${item#*/}"
done
file="${ROOT}${NEWS_DIR}/news-${repo}.${stat}"
- if [[ ! -w ${file} ]]; then
+ for item in ${update}; do
+ echo "${item}"
+ done >"${file}"
+ if [[ $? -ne 0 ]]; then
write_error_msg \
"Cannot update list of news items for repository \"${repo}\""
return 1
fi
- for item in ${update}; do
- echo "${item}"
- done >"${file}" || die "Error writing file ${file}"
+ # GLEP 42 says the file should be in the portage group and group writable
+ chgrp portage "${file}" 2>/dev/null && chmod 664 "${file}" 2>/dev/null
+ return 0
}
# read a given item
@@ -159,6 +162,7 @@ describe_read_options() {
echo "new : Read unread news items (default)"
echo "all : Read all news items"
echo "item : Number of item (from 'list' action)"
+ echo "--raw : Output in raw format"
}
describe_read_parameters() {
@@ -168,9 +172,14 @@ describe_read_parameters() {
do_read() {
package-manager &>/dev/null # for internal caching
local -a items=( $(find_items unread read) ) repos dirs
- local n=${#items[@]} item repo stat dir header line i seq repos_upd
+ local n=${#items[@]} item repo stat dir header line i seq repos_upd raw
local ifs_save=${IFS-$' \t\n'}
+ if [[ $1 = --raw ]]; then
+ raw=1
+ shift
+ fi
+
# expand special values "new" and "all"
if [[ $# -eq 0 || $1 = new || $1 = all ]]; then
for (( i = 1; i <= n; i++ )); do
@@ -190,21 +199,25 @@ do_read() {
stat=${item%%/*}; item=${item#*/}
repo=${item%%/*}; item=${item#*/}
find_repo_dir ${repo}
- write_list_start "${item}"
- header=$(read_item "${dir}" "${item}" header)
- IFS=$'\n'
- for line in ${header}; do
- case "${line%%: *}" in
- Title)
- write_kv_list_entry \
- "${line%%: *}" "$(highlight "${line#*: }")" ;;
- Author|Posted|Revision)
- write_kv_list_entry "${line%%: *}" "${line#*: }" ;;
- esac
- done
- IFS=${ifs_save}
- echo
- read_item "${dir}" "${item}" body
+ if [[ -n ${raw} ]]; then
+ read_item "${dir}" "${item}"
+ else
+ write_list_start "${item}"
+ header=$(read_item "${dir}" "${item}" header)
+ IFS=$'\n'
+ for line in ${header}; do
+ case "${line%%: *}" in
+ Title)
+ write_kv_list_entry \
+ "${line%%: *}" "$(highlight "${line#*: }")" ;;
+ Author|Posted|Revision)
+ write_kv_list_entry "${line%%: *}" "${line#*: }" ;;
+ esac
+ done
+ IFS=${ifs_save}
+ echo
+ read_item "${dir}" "${item}" body
+ fi
echo
[[ ${stat} = unread ]] || continue