summaryrefslogtreecommitdiff
path: root/fml/lib
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-11-19 08:49:30 +0000
committerfukachan <fukachan>2001-11-19 08:49:30 +0000
commit822d556ebaa019f9bca50e1b39d8273babfb12ae (patch)
treefcca1c7674ca6a0295198470f553a52fb9b49d2c /fml/lib
parentd73483302295faa4d0a1c58a3cfab4ef3c169557 (diff)
downloadfml8-822d556ebaa019f9bca50e1b39d8273babfb12ae.tar.gz
fml8-822d556ebaa019f9bca50e1b39d8273babfb12ae.tar.bz2
fml8-822d556ebaa019f9bca50e1b39d8273babfb12ae.zip
split functions for list and summary.
"list" shows thread summary but "summary" shows thread summary + article summary. enhance fmlthread to provide CUI, oh this is useful !
Diffstat (limited to 'fml/lib')
-rw-r--r--fml/lib/FML/Process/ThreadTrack.pm125
-rw-r--r--fml/lib/Mail/ThreadTrack/Print.pm39
2 files changed, 157 insertions, 7 deletions
diff --git a/fml/lib/FML/Process/ThreadTrack.pm b/fml/lib/FML/Process/ThreadTrack.pm
index 79883f38..55c15930 100644
--- a/fml/lib/FML/Process/ThreadTrack.pm
+++ b/fml/lib/FML/Process/ThreadTrack.pm
@@ -4,7 +4,7 @@
# Copyright (C) 2000-2001 Ken'ichi Fukamachi
# All rights reserved.
#
-# $FML: ThreadTrack.pm,v 1.13 2001/11/18 06:42:17 fukachan Exp $
+# $FML: ThreadTrack.pm,v 1.14 2001/11/18 08:57:29 fukachan Exp $
#
package FML::Process::ThreadTrack;
@@ -92,6 +92,7 @@ sub run
db_base_dir => $thread_db_dir,
ml_name => $ml_name,
spool_dir => $spool_dir,
+ max_id => $max_id,
reverse_order => (defined $options->{ reverse } ? 1 : 0),
};
@@ -106,7 +107,10 @@ sub run
$curproc->lock();
- if ($command eq 'list' || $command eq 'summary') {
+ if ($command eq 'list') {
+ $thread->list();
+ }
+ elsif ($command eq 'summary') {
$thread->summary();
}
elsif ($command eq 'review') {
@@ -138,7 +142,14 @@ sub run
}
}
else {
- help();
+ if ($argv->[ 0 ] ne '') {
+ push(@ISA, 'FML::Process::ThreadTrack::CUI');
+ $ttargs->{ ml_name } = $argv->[ 0 ];
+ $curproc->interactive($args, $thread, $ttargs);
+ }
+ else {
+ help();
+ }
}
$curproc->unlock();
@@ -247,6 +258,7 @@ $name db_clear \$ml_name clear thread database for \$ml_name ML
_EOF_
}
+
sub DESTROY {}
# Descriptions: dummy routine to avoid errors
@@ -261,6 +273,113 @@ sub AUTOLOAD
}
+package FML::Process::ThreadTrack::CUI;
+
+use vars qw($debug @ISA @EXPORT @EXPORT_OK);
+use strict;
+use Carp;
+
+
+sub interactive
+{
+ my ($curproc, $args, $thread, $ttargs) = @_;
+
+ eval q{
+ use Term::ReadLine;
+ my $term = new Term::ReadLine "fmlthread";
+ my $ml_name = $ttargs->{ ml_name };
+ my $prompt = "$ml_name thread> ";
+ my $OUT = $term->OUT || \*STDOUT;
+ my $res = '';
+
+ # main loop;
+ no strict;
+ while ( defined ($_ = $term->readline($prompt)) ) {
+ _exec($curproc, $args, $thread, $ttargs, $_);
+ warn $@ if $@;
+ $term->addhistory($_) if /\S/;
+ }
+ };
+ carp($@) if $@;
+}
+
+
+sub _exec
+{
+ my ($curproc, $args, $xthread, $ttargs, $buf) = @_;
+ my ($command, @argv) = ();
+
+ use Mail::ThreadTrack;
+ my $thread = new Mail::ThreadTrack $ttargs;
+ $thread->set_mode('text');
+
+ # clean up
+ if (defined $buf && $buf) {
+ $buf =~ s/^\s*//;
+ $buf =~ s/\s*$//;
+ ($command, @argv) = split(/\s+/, $buf);
+ }
+
+ if ($command eq '') {
+ help();
+ }
+ elsif ($command eq 'quit' || $command eq 'exit' || $command eq 'end') {
+ exit(0);
+ }
+ elsif ($command eq 'list') {
+ $thread->list();
+ }
+ elsif ($command eq 'show') {
+ for my $id (@argv) {
+ if ($id =~ /^\d+$/) {
+ my $xid = $thread->_create_thread_id_strings($id);
+ use FileHandle;
+ my $wh = new FileHandle "| less";
+ my $saved_fd = $thread->get_fd( $wh );
+ $thread->set_fd( $wh );
+ $thread->show($xid);
+ $thread->set_fd( $saved_fd );
+ }
+ else {
+ print "sorry, cannot show $id\n";
+ }
+ }
+ }
+ elsif ($command eq 'close') {
+ my $max_id = $ttargs->{ max_id };
+ for my $id (@argv) {
+ print "close $id\n";
+ &FML::Process::ThreadTrack::_close($thread, $id, 1, $max_id);
+ }
+ }
+ else {
+ help();
+ }
+}
+
+
+#
+# commands
+#
+
+sub help
+{
+ print "Usage: $0\n\n";
+
+ print "list show thread summary (without article summary)\n";
+ print "show id(s) show articles in thread_id\n";
+ print "close id(s) close thread specified by thread_id\n";
+ print "quit to end\n";
+ print "Ctl-D to end\n";
+ print "\n";
+ print "Typical Usage:\n";
+ print " > list\n ... \n";
+ print " > show 100\n";
+ print " > close 100\n";
+ print "\n";
+}
+
+
=head1 AUTHOR
Ken'ichi Fukamachi
diff --git a/fml/lib/Mail/ThreadTrack/Print.pm b/fml/lib/Mail/ThreadTrack/Print.pm
index af8bf132..8c937d0d 100644
--- a/fml/lib/Mail/ThreadTrack/Print.pm
+++ b/fml/lib/Mail/ThreadTrack/Print.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: Print.pm,v 1.15 2001/11/11 00:57:35 fukachan Exp $
+# $FML: Print.pm,v 1.16 2001/11/11 11:12:28 fukachan Exp $
#
package Mail::ThreadTrack::Print;
@@ -52,6 +52,21 @@ show a chain of article summary in each thread.
# Arguments: $self varargs ...
# Side Effects: none
# Return Value: none
+sub list
+{
+ my ($self, @opts) = @_;
+
+ $self->_load_library();
+ $self->db_open();
+ $self->_do_list(@opts);
+ $self->db_close();
+}
+
+
+# Descriptions: top level entrance for "show" mode
+# Arguments: $self varargs ...
+# Side Effects: none
+# Return Value: none
sub summary
{
my ($self, @opts) = @_;
@@ -110,15 +125,28 @@ sub _load_library
# SUMMARY MODE
#
+sub _do_summary
+{
+ my ($self) = @_;
+ $self->__do_summary( { mode => 'summary' });
+}
+
+
+sub _do_list
+{
+ my ($self) = @_;
+ $self->__do_summary( { mode => 'list' });
+}
+
# Descriptions: get thread id list with status != 'open' and
# show summary for the list
# Arguments: $self
# Side Effects: none
# Return Value: none
-sub _do_summary
+sub __do_summary
{
- my ($thread) = @_;
+ my ($thread, $option) = @_;
my $mode = $thread->get_mode || 'text';
# rh: thread id list picked from status.db
@@ -130,7 +158,10 @@ sub _do_summary
if (@$thread_id_list) {
$thread->sort_thread_id($thread_id_list);
$thread->_print_thread_summary($thread_id_list);
- $thread->_print_message_summary($thread_id_list);
+
+ if ($option->{ mode } eq 'summary') {
+ $thread->_print_message_summary($thread_id_list);
+ }
}
}