user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 08/10] watch: add --help/-h support
Date: Tue,  1 Sep 2020 01:15:05 +0000	[thread overview]
Message-ID: <20200901011507.1643-9-e@80x24.org> (raw)
In-Reply-To: <20200901011507.1643-1-e@80x24.org>

And avoid unnecessary POD markup in the man page.
---
 Documentation/public-inbox-watch.pod |  2 +-
 script/public-inbox-watch            | 18 ++++++++++++++----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/Documentation/public-inbox-watch.pod b/Documentation/public-inbox-watch.pod
index f3e622b0..73340ec4 100644
--- a/Documentation/public-inbox-watch.pod
+++ b/Documentation/public-inbox-watch.pod
@@ -4,7 +4,7 @@ public-inbox-watch - mailbox watcher for public-inbox
 
 =head1 SYNOPSIS
 
-B<public-inbox-watch>
+	public-inbox-watch
 
 In ~/.public-inbox/config:
 
diff --git a/script/public-inbox-watch b/script/public-inbox-watch
index b6c6b202..1d164aa3 100755
--- a/script/public-inbox-watch
+++ b/script/public-inbox-watch
@@ -1,13 +1,24 @@
 #!/usr/bin/perl -w
 # Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+my $help = <<EOF;
+usage: public-inbox-watch
+
+See public-inbox-watch(1) man page for full documentation.
+EOF
+
 use strict;
-use IO::Handle;
+use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev);
+use IO::Handle; # ->autoflush
 use PublicInbox::Watch;
 use PublicInbox::Config;
 use PublicInbox::DS;
 use PublicInbox::Sigfd;
 use PublicInbox::Syscall qw($SFD_NONBLOCK);
+my $do_scan = 1;
+GetOptions('scan!' => \$do_scan, # undocumented, testing only
+	'help|h' => \(my $show_help)) or do { print STDERR $help; exit 1 };
+if ($show_help) { print $help; exit 0 };
 my $oldset = PublicInbox::Sigfd::block_signals();
 STDOUT->autoflush(1);
 STDERR->autoflush(1);
@@ -44,9 +55,8 @@ if ($watch) {
 	$sig->{QUIT} = $sig->{TERM} = $sig->{INT} = $quit;
 
 	# --no-scan is only intended for testing atm, undocumented.
-	unless (grep(/\A--no-scan\z/, @ARGV)) {
-		PublicInbox::DS::requeue($scan);
-	}
+	PublicInbox::DS::requeue($scan) if $do_scan;
+
 	my $sigfd = PublicInbox::Sigfd->new($sig, $SFD_NONBLOCK);
 	local %SIG = (%SIG, %$sig) if !$sigfd;
 	if (!$sigfd) {

  parent reply	other threads:[~2020-09-01  1:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-01  1:14 [PATCH 00/10] some usability tweaks Eric Wong
2020-09-01  1:14 ` [PATCH 01/10] script/*: set executable bit on -learn and -imapd Eric Wong
2020-09-01  1:14 ` [PATCH 02/10] admin: improve minimum version text Eric Wong
2020-09-01  1:15 ` [PATCH 03/10] edit+purge: support `--help' and `-h' like other commands Eric Wong
2020-09-01  1:15 ` [PATCH 04/10] script/*: fold $usage into $help, support `-h' instead of -? Eric Wong
2020-09-01  1:15 ` [PATCH 05/10] daemon: support --help/-h in -httpd/imapd/nntpd Eric Wong
2020-09-01  1:15 ` [PATCH 06/10] mda+learn: add --help / -h support Eric Wong
2020-09-01  1:15 ` [PATCH 07/10] config: use defined-or (//) in a few places Eric Wong
2020-09-01  1:15 ` Eric Wong [this message]
2020-09-01  1:15 ` [PATCH 09/10] doc: remove B<> (bold) markup from the remaining POD Eric Wong
2020-09-01  1:15 ` [PATCH 10/10] init+convert: create non-existing directory hierarchies Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200901011507.1643-9-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).