user/dev discussion of public-inbox itself
 help / color / mirror / Atom feed
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
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";

  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

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git