Mercurial > hg > egg-tcls
comparison tj.tcl @ 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 |
comparison
equal
deleted
inserted
replaced
615:1dac9129eb0f | 616:20dba2c757de |
---|---|
379 | 379 |
380 } elseif {[tj_cmd_match "list" $rcmd]} { | 380 } elseif {[tj_cmd_match "list" $rcmd]} { |
381 # !tj list | 381 # !tj list |
382 # List reminders | 382 # List reminders |
383 set uclock [clock seconds] | 383 set uclock [clock seconds] |
384 set nresults 0 | 384 |
385 set usql "SELECT COUNT(*) FROM tj WHERE uuser='[utl_escape $uhand]'" | |
386 if {[catch {set nitems [tj_dbh onecolumn $usql]} uerrmsg]} { | |
387 tj_msg $upublic $unick $uchan "err_sql" [list $uerrmsg] | |
388 tj_log "$uerrmsg on SQL:\n$usql" | |
389 return 1 | |
390 } | |
391 | |
392 set nitem 0 | |
385 set usql "SELECT * FROM tj WHERE uuser='[utl_escape $uhand]' ORDER BY ucreated" | 393 set usql "SELECT * FROM tj WHERE uuser='[utl_escape $uhand]' ORDER BY ucreated" |
386 tj_dbh eval $usql { | 394 tj_dbh eval $usql { |
387 incr nresults | 395 incr nitem |
388 tj_msg $upublic $unick $uchan "#${nresults}: $utype : $utarget : $uid : $udesc" | 396 set ustamp [utl_sql_datetime_to_stamp $utarget] |
389 } | 397 tj_msg $upublic $unick $uchan "list_item" [list $nitem $nitems [tj_ctime $ustamp] $uid $udesc] |
390 | 398 } |
391 if {!$nresults} { | 399 |
400 if {!$nitem} { | |
392 tj_msg $upublic $unick $uchan "no_results" [list $uname] | 401 tj_msg $upublic $unick $uchan "no_results" [list $uname] |
393 } | 402 } |
394 | 403 |
395 } elseif {[tj_cmd_match "delete" $rcmd]} { | 404 } elseif {[tj_cmd_match "delete" $rcmd]} { |
396 # !tj delete <id> | 405 # !tj delete <id> |