]> Sergey Matveev's repositories - public-inbox.git/commitdiff
edit+purge: support `--help' and `-h' like other commands
authorEric Wong <e@80x24.org>
Tue, 1 Sep 2020 01:15:00 +0000 (01:15 +0000)
committerEric Wong <e@80x24.org>
Wed, 2 Sep 2020 08:53:54 +0000 (08:53 +0000)
And while we're at it, note edit is *destructive* to encourage
reading the fine manual.

Documentation/public-inbox-edit.pod
lib/PublicInbox/AdminEdit.pm
script/public-inbox-edit
script/public-inbox-purge

index 68180872047ddf8cbcb216dcfc7278db86c88f86..55d1c1630533fd126f36f28ec34dfc31235e9c40 100644 (file)
@@ -1,6 +1,6 @@
 =head1 NAME
 
-public-inbox-edit - edit messages in a public inbox
+public-inbox-edit - destructively edit messages in a public inbox
 
 =head1 SYNOPSIS
 
index 25abfd8e7683c1d9df52d42e9bb0dc20c3c7badd..4448dcc292767ab94c3dcb35397fce0094befcc9 100644 (file)
@@ -6,7 +6,7 @@ package PublicInbox::AdminEdit;
 use strict;
 use warnings;
 use PublicInbox::Admin;
-our @OPT = qw(all force|f verbose|v!);
+our @OPT = qw(all force|f verbose|v! help|h);
 
 sub check_editable ($) {
        my ($ibxs) = @_;
index 240beb3a168ff3e6c6a35e4814b3cab144761642..a70614fc2a4074e1c35485a2a290ddefe7ab0249 100755 (executable)
@@ -16,11 +16,26 @@ use PublicInbox::Eml;
 use PublicInbox::InboxWritable qw(eml_from_path);
 use PublicInbox::Import;
 
-my $usage = "$0 -m MESSAGE_ID [--all] [INBOX_DIRS]";
+my $help = <<'EOF';
+usage: public-inbox-edit -m MESSAGE-ID [--all] [INBOX_DIRS]
+
+  destructively edit messages in a public inbox
+
+options:
+
+  --all               edit all configured inboxes
+  -m MESSAGE-ID       edit the message with a given Message-ID
+  -F FILE             edit the message matching the contents of FILE
+  --force             forcibly edit even if Message-ID is ambiguous
+  --raw               do not perform "From " line escaping
+
+See public-inbox-edit(1) man page for full documentation.
+EOF
+
 my $opt = { verbose => 1, all => 0, -min_inbox_version => 2, raw => 0 };
 my @opt = qw(mid|m=s file|F=s raw);
-GetOptions($opt, @PublicInbox::AdminEdit::OPT, @opt) or
-       die "bad command-line args\n$usage\n";
+GetOptions($opt, @PublicInbox::AdminEdit::OPT, @opt) or die $help;
+if ($opt->{help}) { print $help; exit 0 };
 
 my $cfg = PublicInbox::Config->new;
 my $editor = $ENV{MAIL_EDITOR}; # e.g. "mutt -f"
index 82a63b80265110b11e5ee3826ea7827495ff29cf..7bca11eafc6fc81f1566a6c8fc6b37e27817e6fb 100755 (executable)
@@ -13,10 +13,21 @@ use PublicInbox::Filter::Base qw(REJECT);
 use PublicInbox::Eml;
 require PublicInbox::V2Writable;
 
-my $usage = "$0 [--all] [INBOX_DIRS] </path/to/message";
+my $help = <<EOF;
+usage: public-inbox-purge [--all] [INBOX_DIRS] </path/to/message
+
+  erase message entirely from an inbox (including history)
+
+options:
+
+  --all               purge from all configured inboxes
+
+See public-inbox-purge(1) man page for full documentation.
+EOF
+
 my $opt = { verbose => 1, all => 0, -min_inbox_version => 2 };
-GetOptions($opt, @PublicInbox::AdminEdit::OPT) or
-       die "bad command-line args\n$usage\n";
+GetOptions($opt, @PublicInbox::AdminEdit::OPT) or die $help;
+if ($opt->{help}) { print $help; exit 0 };
 
 my @ibxs = PublicInbox::Admin::resolve_inboxes(\@ARGV, $opt);
 PublicInbox::AdminEdit::check_editable(\@ibxs);