]> Sergey Matveev's repositories - public-inbox.git/commitdiff
daemon: support --help/-h in -httpd/imapd/nntpd
authorEric Wong <e@80x24.org>
Tue, 1 Sep 2020 01:15:02 +0000 (01:15 +0000)
committerEric Wong <e@80x24.org>
Wed, 2 Sep 2020 08:53:56 +0000 (08:53 +0000)
For consistency with other commands, though the
protocol-specific options should refer users to
the manpage.

lib/PublicInbox/Daemon.pm

index 000ba1695d666bb7eed68677b5418e7bb8bbe23a..e5798a4bf2276abd3e9e6c1aa7c1bff5cd055e99 100644 (file)
@@ -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";