Mercurial > hg > egg-tcls
changeset 616:20dba2c757de
tj: Improve output of 'list' command, and make it configurable.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 10 Feb 2021 13:36:31 +0200 |
parents | 1dac9129eb0f |
children | ce7a666991e3 |
files | config.tj.example tj.tcl |
diffstat | 2 files changed, 17 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/config.tj.example Wed Feb 10 12:34:12 2021 +0200 +++ b/config.tj.example Wed Feb 10 13:36:31 2021 +0200 @@ -72,11 +72,13 @@ "help_set" "@cmd@ set \[#id\] <\[-\]päivät \[+/-<tunnit>\] | dd.mm.yyyy \[hh:mm\]> [<kuvaus>]" "help_list" "@cmd@ list" + "help_remind_add" "@cmd@ muistuta <id>" + "help_remind_delete" "@cmd@ poista <id>" + "err_invalid_user" "Pyh, mene pois." "err_unknown_user" "en tunne @1@" - "help_remind_add" "@cmd@ muistuta <id>" - "help_remind_delete" "@cmd@ poista <id>" + "list_item" "#@1@/@2@: @3@ : \002@4@\002 / @5@" "tj_set" "@3@:n @2@-TJ asetettu @5@ (@6@): @4@" "tj_updated" "@3@:n @2@-TJ päivitetty @5@ (@6@): @4@"
--- a/tj.tcl Wed Feb 10 12:34:12 2021 +0200 +++ b/tj.tcl Wed Feb 10 13:36:31 2021 +0200 @@ -381,14 +381,23 @@ # !tj list # List reminders set uclock [clock seconds] - set nresults 0 + + set usql "SELECT COUNT(*) FROM tj WHERE uuser='[utl_escape $uhand]'" + if {[catch {set nitems [tj_dbh onecolumn $usql]} uerrmsg]} { + tj_msg $upublic $unick $uchan "err_sql" [list $uerrmsg] + tj_log "$uerrmsg on SQL:\n$usql" + return 1 + } + + set nitem 0 set usql "SELECT * FROM tj WHERE uuser='[utl_escape $uhand]' ORDER BY ucreated" tj_dbh eval $usql { - incr nresults - tj_msg $upublic $unick $uchan "#${nresults}: $utype : $utarget : $uid : $udesc" + incr nitem + set ustamp [utl_sql_datetime_to_stamp $utarget] + tj_msg $upublic $unick $uchan "list_item" [list $nitem $nitems [tj_ctime $ustamp] $uid $udesc] } - if {!$nresults} { + if {!$nitem} { tj_msg $upublic $unick $uchan "no_results" [list $uname] }