* [PATCH 22/30] init: drop extraneous `+'
@ 2023-10-17 23:38 6% ` Eric Wong
0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2023-10-17 23:38 UTC (permalink / raw)
To: meta
It's actually valid Perl syntax, but still confusing to look at.
Fixes: add90b9504f4 ("support -C (chdir) for most non-daemon commands")
---
script/public-inbox-init | 2 +-
t/init.t | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/script/public-inbox-init b/script/public-inbox-init
index 33bee310..b3e94faf 100755
--- a/script/public-inbox-init
+++ b/script/public-inbox-init
@@ -60,7 +60,7 @@ my $inboxdir = shift @ARGV or $usage_cb->();
my $http_url = shift @ARGV or $usage_cb->();
my (@address) = @ARGV;
@address or $usage_cb->();
-+PublicInbox::Admin::do_chdir(\@chdir);
+PublicInbox::Admin::do_chdir(\@chdir);
@c_extra = map {
my ($k, $v) = split(/=/, $_, 2);
diff --git a/t/init.t b/t/init.t
index abe3a372..177c22b6 100644
--- a/t/init.t
+++ b/t/init.t
@@ -216,6 +216,13 @@ SKIP: {
is($n, 13, 'V1 NNTP article numbers skipped via --skip-artnum');
}
+{
+ my $cmd = [ qw(-init -C), "$tmpdir", qw(chdirlist chdirlist),
+ qw(http://example.com/chdirlist chdirlist@example.com)];
+ ok(run_script($cmd), '-init with -C (chdir)');
+ ok(-d "$tmpdir/chdirlist", '-C processed correctly');
+}
+
done_testing();
sub read_indexlevel {
^ permalink raw reply related [relevance 6%]
* [PATCH 5/5] support -C (chdir) for most non-daemon commands
2021-09-15 21:35 7% [PATCH 0/5] make(1) inspired things Eric Wong
@ 2021-09-15 21:35 5% ` Eric Wong
0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2021-09-15 21:35 UTC (permalink / raw)
To: meta
Because make(1), git(1), tar(1) all support -C in this form, as
do our newer commands such as lei, public-inbox-{clone,fetch}.
---
script/public-inbox-compact | 3 ++-
script/public-inbox-convert | 6 +++---
script/public-inbox-edit | 3 ++-
script/public-inbox-extindex | 3 ++-
script/public-inbox-index | 3 ++-
script/public-inbox-init | 4 +++-
script/public-inbox-purge | 3 ++-
script/public-inbox-xcpdb | 3 ++-
8 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/script/public-inbox-compact b/script/public-inbox-compact
index 6e34aaeb..80d0224b 100755
--- a/script/public-inbox-compact
+++ b/script/public-inbox-compact
@@ -17,7 +17,7 @@ options:
See public-inbox-compact(1) man page for full documentation.
EOF
-GetOptions($opt, qw(all help|h),
+GetOptions($opt, qw(all C=s@ help|h),
# compact options:
qw(jobs|j=i quiet|q blocksize|b=s no-full|n fuller|F),
) or die $help;
@@ -25,6 +25,7 @@ if ($opt->{help}) { print $help; exit 0 };
require PublicInbox::Admin;
PublicInbox::Admin::require_or_die('-index');
+PublicInbox::Admin::do_chdir(delete $opt->{C});
PublicInbox::Admin::progress_prepare($opt);
require PublicInbox::InboxWritable;
diff --git a/script/public-inbox-convert b/script/public-inbox-convert
index 01af846a..42955a48 100755
--- a/script/public-inbox-convert
+++ b/script/public-inbox-convert
@@ -33,7 +33,7 @@ my $opt = {
quiet => -1, compact => 0, maxsize => undef, fsync => 1,
reindex => 1, # we always reindex
};
-GetOptions($opt, qw(jobs|j=i index! help|h),
+GetOptions($opt, qw(jobs|j=i index! help|h C=s@),
# index options
qw(verbose|v+ rethread compact|c+ fsync|sync!
indexlevel|index-level|L=s max_size|max-size=s
@@ -41,13 +41,14 @@ GetOptions($opt, qw(jobs|j=i index! help|h),
sequential-shard|seq-shard
)) or die $help;
if ($opt->{help}) { print $help; exit 0 };
+require PublicInbox::Admin;
+PublicInbox::Admin::do_chdir(delete $opt->{C});
my $old_dir = shift(@ARGV) // '';
my $new_dir = shift(@ARGV) // '';
die $help if (scalar(@ARGV) || $new_dir eq '' || $old_dir eq '');
die "$new_dir exists\n" if -d $new_dir;
die "$old_dir not a directory\n" unless -d $old_dir;
-require PublicInbox::Admin;
require PublicInbox::Config;
require PublicInbox::InboxWritable;
@@ -62,7 +63,6 @@ if (delete $old->{-unconfigured}) {
}
die "Only conversion from v1 inboxes is supported\n" if $old->version >= 2;
-require PublicInbox::Admin;
my $detected = PublicInbox::Admin::detect_indexlevel($old);
$old->{indexlevel} //= $detected;
my $env;
diff --git a/script/public-inbox-edit b/script/public-inbox-edit
index 9498038b..1fbaf5a7 100755
--- a/script/public-inbox-edit
+++ b/script/public-inbox-edit
@@ -33,9 +33,10 @@ 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);
+my @opt = qw(mid|m=s file|F=s raw C=s@);
GetOptions($opt, @PublicInbox::AdminEdit::OPT, @opt) or die $help;
if ($opt->{help}) { print $help; exit 0 };
+PublicInbox::Admin::do_chdir(delete $opt->{C});
my $cfg = PublicInbox::Config->new;
my $editor = $ENV{MAIL_EDITOR}; # e.g. "mutt -f"
diff --git a/script/public-inbox-extindex b/script/public-inbox-extindex
index 327980d2..1572a1d2 100755
--- a/script/public-inbox-extindex
+++ b/script/public-inbox-extindex
@@ -30,7 +30,7 @@ GetOptions($opt, qw(verbose|v+ reindex rethread compact|c+ jobs|j=i
indexlevel|index-level|L=s max_size|max-size=s
batch_size|batch-size=s
dedupe:s@ gc commit-interval=i watch scan! dry-run|n
- all help|h))
+ all C=s@ help|h))
or die $help;
if ($opt->{help}) { print $help; exit 0 };
die "--jobs must be >= 0\n" if defined $opt->{jobs} && $opt->{jobs} < 0;
@@ -40,6 +40,7 @@ STDERR->autoflush(1);
local $SIG{USR1} = 'IGNORE'; # to be overridden in eidx_sync
# require lazily to speed up --help
require PublicInbox::Admin;
+PublicInbox::Admin::do_chdir(delete $opt->{C});
my $cfg = PublicInbox::Config->new;
my $eidx_dir = shift(@ARGV);
unless (defined $eidx_dir) {
diff --git a/script/public-inbox-index b/script/public-inbox-index
index 0034d44c..ca190a2e 100755
--- a/script/public-inbox-index
+++ b/script/public-inbox-index
@@ -42,7 +42,7 @@ GetOptions($opt, qw(verbose|v+ reindex rethread compact|c+ jobs|j=i prune
batch_size|batch-size=s
sequential-shard|seq-shard
no-update-extindex update-extindex|E=s@
- fast-noop|F skip-docdata all help|h))
+ fast-noop|F skip-docdata all C=s@ help|h))
or die $help;
if ($opt->{help}) { print $help; exit 0 };
die "--jobs must be >= 0\n" if defined $opt->{jobs} && $opt->{jobs} < 0;
@@ -56,6 +56,7 @@ if ($opt->{reindex} && delete($opt->{'fast-noop'})) {
# require lazily to speed up --help
require PublicInbox::Admin;
PublicInbox::Admin::require_or_die('-index');
+PublicInbox::Admin::do_chdir(delete $opt->{C});
my $cfg = PublicInbox::Config->new; # Config is loaded by Admin
$opt->{-use_cwd} = 1;
diff --git a/script/public-inbox-init b/script/public-inbox-init
index 78a4d3bd..1223d47e 100755
--- a/script/public-inbox-init
+++ b/script/public-inbox-init
@@ -36,7 +36,7 @@ PublicInbox::Admin::require_or_die('-base');
my ($version, $indexlevel, $skip_epoch, $skip_artnum, $jobs, $show_help);
my $skip_docdata;
my $ng = '';
-my @c_extra;
+my (@c_extra, @chdir);
my %opts = (
'V|version=i' => \$version,
'L|index-level|indexlevel=s' => \$indexlevel,
@@ -47,6 +47,7 @@ my %opts = (
'skip-docdata' => \$skip_docdata,
'help|h' => \$show_help,
'c=s@' => \@c_extra,
+ 'C=s@' => \@chdir,
);
my $usage_cb = sub {
print STDERR $help;
@@ -59,6 +60,7 @@ my $inboxdir = shift @ARGV or $usage_cb->();
my $http_url = shift @ARGV or $usage_cb->();
my (@address) = @ARGV;
@address or $usage_cb->();
++PublicInbox::Admin::do_chdir(\@chdir);
@c_extra = map {
my ($k, $v) = split(/=/, $_, 2);
diff --git a/script/public-inbox-purge b/script/public-inbox-purge
index 59c03150..121027cc 100755
--- a/script/public-inbox-purge
+++ b/script/public-inbox-purge
@@ -26,9 +26,10 @@ 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 $help;
+GetOptions($opt, @PublicInbox::AdminEdit::OPT, 'C=s@') or die $help;
if ($opt->{help}) { print $help; exit 0 };
+PublicInbox::Admin::do_chdir(delete $opt->{C});
my @ibxs = PublicInbox::Admin::resolve_inboxes(\@ARGV, $opt);
PublicInbox::AdminEdit::check_editable(\@ibxs);
diff --git a/script/public-inbox-xcpdb b/script/public-inbox-xcpdb
index 81d1a85b..24fc5a25 100755
--- a/script/public-inbox-xcpdb
+++ b/script/public-inbox-xcpdb
@@ -33,11 +33,12 @@ GetOptions($opt, qw(
sequential-shard|seq-shard
jobs|j=i quiet|q verbose|v
blocksize|b=s no-full|n fuller|F
- all help|h)) or die $help;
+ all C=s@ help|h)) or die $help;
if ($opt->{help}) { print $help; exit 0 };
use PublicInbox::Admin;
PublicInbox::Admin::require_or_die('-search');
+PublicInbox::Admin::do_chdir(delete $opt->{C});
require PublicInbox::Config;
my $cfg = PublicInbox::Config->new;
^ permalink raw reply related [relevance 5%]
* [PATCH 0/5] make(1) inspired things
@ 2021-09-15 21:35 7% Eric Wong
2021-09-15 21:35 5% ` [PATCH 5/5] support -C (chdir) for most non-daemon commands Eric Wong
0 siblings, 1 reply; 3+ results
From: Eric Wong @ 2021-09-15 21:35 UTC (permalink / raw)
To: meta
make(1) is familiar to most, so maybe it'll help users learn
unfamiliar with public-inbox-* stuff.
Eric Wong (5):
fetch: support --exit-code switch
TODO: update some items
clone|fetch|--mirror: add convenience $INBOX_DIR/Makefile
fetch|clone|--mirror: shorten paths for progress output
support -C (chdir) for most non-daemon commands
Documentation/public-inbox-fetch.pod | 30 +++++++++++-
TODO | 15 ++----
lib/PublicInbox/Fetch.pm | 42 +++++++++++-----
lib/PublicInbox/LeiMirror.pm | 73 +++++++++++++++++++++++++---
script/public-inbox-compact | 3 +-
script/public-inbox-convert | 6 +--
script/public-inbox-edit | 3 +-
script/public-inbox-extindex | 3 +-
script/public-inbox-fetch | 4 +-
script/public-inbox-index | 3 +-
script/public-inbox-init | 4 +-
script/public-inbox-purge | 3 +-
script/public-inbox-xcpdb | 3 +-
t/lei-mirror.t | 22 ++++++---
t/v2mirror.t | 3 +-
15 files changed, 167 insertions(+), 50 deletions(-)
^ permalink raw reply [relevance 7%]
Results 1-3 of 3 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-09-15 21:35 7% [PATCH 0/5] make(1) inspired things Eric Wong
2021-09-15 21:35 5% ` [PATCH 5/5] support -C (chdir) for most non-daemon commands Eric Wong
2023-10-17 23:37 [PATCH 00/30] autodie-ification and code simplifications Eric Wong
2023-10-17 23:38 6% ` [PATCH 22/30] init: drop extraneous `+' Eric Wong
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).