Add a '-b' option, to print the article number bounds of a newsgroup.
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Tue, 21 Feb 2012 20:56:09 +0000 (20:56 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Tue, 21 Feb 2012 20:56:09 +0000 (20:56 +0000)
git-svn-id: svn://svn.tartarus.org/sgt/utils@9418 cda61777-01e9-0310-a592-d414129be87e

nntpid/nntpid
nntpid/nntpid.but

index 015b277..d9619fb 100755 (executable)
@@ -34,6 +34,7 @@ $usage =
   "       -v                  verbose (print interaction with news server)\n" .
   "       -d                  direct output (don't consider using PAGER)\n" .
   "       -a                  dump all articles in group to stdout as mbox\n" .
+  "       -b                  return current bounds on group's article numbers\n" .
   " also: nntpid --version    report version number\n" .
   "       nntpid --help       display this help text\n" .
   "       nntpid --licence    display (MIT) licence text\n";
@@ -70,6 +71,7 @@ while ($ARGV[0] =~ /^-(.+)$/) {
   $verbose = 1, next if $1 eq "v";
   $pager = 0, next if $1 eq "d";
   $mode = 'all', next if $1 eq "a";
+  $mode = 'bounds', next if $1 eq "b";
   if ($1 eq "-help") {
     print STDERR $usage;
     exit 0;
@@ -91,6 +93,10 @@ if ($mode eq 'all') {
   # normal ones..
   die "nntpid: -a expected exactly one argument\n" if @ARGV != 1;
   $group = $ARGV[0];
+} elsif ($mode eq 'bounds') {
+  # -b has similar command-line semantics to -a.
+  die "nntpid: -b expected exactly one argument\n" if @ARGV != 1;
+  $group = $ARGV[0];
 } elsif (!@ARGV) {
   # We will read article ids from standard input once we've connected
   # to the NNTP server.
@@ -142,6 +148,11 @@ if ($mode eq 'all') {
       print "From nntpid ".(localtime)."\n".$art."\n";
     }
   }
+} elsif ($mode eq 'bounds') {
+  # Write out the bounds of the group's article numbers.
+  $numbers = &docmd("GROUP $group");
+  @numbers = split / /, $numbers;
+  print "$numbers[1] $numbers[2]\n";
 } elsif ($mode eq 'stdin') {
   while (<>) {
     chomp;
index ee6f026..cffd9b1 100644 (file)
@@ -40,9 +40,12 @@ that cause unexpected behaviour in your terminal. If \cw{nntpid}
 detects that its standard output is not a terminal, however, it will
 bypass the pager and just write out the article directly.
 
-There is an alternative mode of operation, enabled by the \cw{-a}
-option, in which \cw{nntpid} retrieves \e{all} available articles in
-the group and writes them to standard output in \cw{mbox} format.
+There are a couple of alternative mode of operation. In one, enabled
+by the \cw{-a} option, \cw{nntpid} retrieves \e{all} available
+articles in the group and writes them to standard output in \cw{mbox}
+format. In the other, enabled with \cw{-b}, \cw{nntpid} simply prints
+the lowest and highest article numbers currently available in that
+group from the news server.
 
 The location of the news server is obtained by reading the
 environment variable \cw{NNTPSERVER}, or failing that the file
@@ -103,6 +106,13 @@ straight to standard output without bothering to try using a pager.
 \cw{nntpid} will always write straight to standard output (so the
 \cw{-d} option is unnecessary).
 
+\dt \cw{-b}
+
+\dd Print the current bounds on that group's article numbers. The
+output is one line consisting of a minimum and maximum article number.
+(Not every article in that range will necessarily actually exist: a
+cancelled article will still use up a space in the numbering range.)
+
 \U AUTHENTICATION
 
 Currently, the only form of authentication supported by \cw{nntpid}