From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 05/10] daemon: support --help/-h in -httpd/imapd/nntpd
Date: Tue, 1 Sep 2020 01:15:02 +0000 [thread overview]
Message-ID: <20200901011507.1643-6-e@80x24.org> (raw)
In-Reply-To: <20200901011507.1643-1-e@80x24.org>
For consistency with other commands, though the
protocol-specific options should refer users to
the manpage.
---
lib/PublicInbox/Daemon.pm | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index 000ba169..e5798a4b 100644
--- a/lib/PublicInbox/Daemon.pm
+++ b/lib/PublicInbox/Daemon.pm
@@ -77,7 +77,20 @@ sub daemon_prepare ($) {
my $listener_names = {}; # sockname => IO::Handle
my $oldset = PublicInbox::Sigfd::block_signals();
@CMD = ($0, @ARGV);
- my %opts = (
+ my ($prog) = ($CMD[0] =~ m!([^/]+)\z!g);
+ my $help = <<EOF;
+usage: $prog [-l ADDRESS] [--cert=FILE] [--key=FILE]
+
+options:
+
+ -l ADDRESS address to listen on (default: $default_listen)
+ --cert=FILE default SSL/TLS certificate
+ --key=FILE default SSL/TLS certificate
+ -W WORKERS number of worker processes to spawn (default: 1)
+
+See public-inbox-daemon(8) and $prog(1) man pages for more.
+EOF
+ my %opt = (
'l|listen=s' => \@cfg_listen,
'1|stdout=s' => \$stdout,
'2|stderr=s' => \$stderr,
@@ -88,8 +101,10 @@ sub daemon_prepare ($) {
'D|daemonize' => \$daemonize,
'cert=s' => \$default_cert,
'key=s' => \$default_key,
+ 'help|h' => \(my $show_help),
);
- GetOptions(%opts) or die "bad command-line args\n";
+ GetOptions(%opt) or die $help;
+ if ($show_help) { print $help; exit 0 };
if (defined $pid_file && $pid_file =~ /\.oldbin\z/) {
die "--pid-file cannot end with '.oldbin'\n";
next prev 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 ` Eric Wong [this message]
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 ` [PATCH 08/10] watch: add --help/-h support Eric Wong
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-6-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).