From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 948BE1FA12 for ; Tue, 1 Sep 2020 01:15:08 +0000 (UTC) From: Eric Wong 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> In-Reply-To: <20200901011507.1643-1-e@80x24.org> References: <20200901011507.1643-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 = < \@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";