X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FLEI.pm;h=ef72758c6d9a060ebe5813a7a8b0fbe8aca437a8;hb=4b9be88e2465ffcbf91901f06e19a749f6bdf818;hp=9f49fc038c8881fad6a7a44a988f2e0ccf5f47e3;hpb=3a6e13b7f3cf04b9a3dd0fdd3ed4d96a05e31e9f;p=public-inbox.git diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 9f49fc03..ef72758c 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -64,9 +64,13 @@ sub opt_dash ($$) { ($spec, '<>' => $cb, $GLP_PASS) # for Getopt::Long } -sub rel2abs ($$) { +# rel2abs preserves symlinks in parent, unlike abs_path +sub rel2abs { my ($self, $p) = @_; - return $p if index($p, '/') == 0; # already absolute + if (index($p, '/') == 0) { # already absolute + $p =~ tr!/!/!s; # squeeze redundant slashes + return $p; + } my $pwd = $self->{env}->{PWD}; my $cwd; if (defined $pwd) { @@ -84,6 +88,9 @@ sub rel2abs ($$) { File::Spec->rel2abs($p, $pwd); } +# abs_path resolves symlinks in parent iff all parents exist +sub abs_path { Cwd::abs_path($_[1]) // rel2abs(@_) } + sub share_path ($) { # $HOME/.local/share/lei/$FOO my ($self) = @_; rel2abs($self, ($self->{env}->{XDG_DATA_HOME} // @@ -142,6 +149,14 @@ our %CMD = ( # sorted in order of importance/use: 'up' => [ 'OUTPUT|--all', 'update saved search', qw(jobs|j=s lock=s@ alert=s@ mua=s verbose|v+ all:s), @c_opt ], +'lcat' => [ '--stdin|MSGID_OR_URL..', 'display local copy of message(s)', + 'stdin|', # /|\z/ must be first for lone dash + # some of these options are ridiculous for lcat + @lxs_opt, qw(output|mfolder|o=s format|f=s dedupe|d=s threads|t+ + sort|s=s reverse|r offset=i jobs|j=s globoff|g augment|a + import-before! lock=s@ rsyncable alert=s@ mua=s verbose|v+), @c_opt, + opt_dash('limit|n=i', '[0-9]+') ], + 'blob' => [ 'OID', 'show a git blob, reconstructing from mail if necessary', qw(git-dir=s@ cwd! verbose|v+ mail! oid-a|A=s path-a|a=s path-b|b=s), @lxs_opt, @c_opt ], @@ -154,6 +169,8 @@ our %CMD = ( # sorted in order of importance/use: 'ls-external' => [ '[FILTER]', 'list publicinbox|extindex locations', qw(format|f=s z|0 globoff|g invert-match|v local remote), @c_opt ], 'ls-label' => [ '', 'list labels', qw(z|0 stats:s), @c_opt ], +'ls-sync' => [ '', 'list sync folders', + qw(z|0 z|0 globoff|g invert-match|v local remote), @c_opt ], 'forget-external' => [ 'LOCATION...|--prune', 'exclude further results from a publicinbox|extindex', qw(prune), @c_opt ], @@ -193,7 +210,7 @@ our %CMD = ( # sorted in order of importance/use: 'import' => [ 'LOCATION...|--stdin', 'one-time import/update from URL or filesystem', qw(stdin| offset=i recursive|r exclude=s include|I=s - lock=s@ in-format|F=s kw! verbose|v+ incremental!), @c_opt ], + lock=s@ in-format|F=s kw! verbose|v+ incremental! sync!), @c_opt ], 'convert' => [ 'LOCATION...|--stdin', 'one-time conversion from URL or filesystem to another format', qw(stdin| in-format|F=s out-format|f=s output|mfolder|o=s @@ -205,6 +222,9 @@ our %CMD = ( # sorted in order of importance/use: 'git-config(1) wrapper for '._config_path($_[0]); }, qw(config-file|system|global|file|f=s), # for conflict detection qw(c=s@ C=s@), pass_through('git config') ], +'inspect' => [ 'ITEMS...', 'inspect lei/store and/or local external', + qw(pretty ascii dir=s), @c_opt ], + 'init' => [ '[DIRNAME]', sub { "initialize storage, default: ".store_path($_[0]); }, @c_opt ], @@ -519,7 +539,7 @@ sub workers_start { 'child_error' => [ \&child_error, $lei ], ($ops ? %$ops : ()), }; - $ops->{''} //= [ \&dclose, $lei ]; + $ops->{''} //= [ $wq->can('_lei_wq_eof') || \&dclose, $lei ]; my $end = $lei->pkt_op_pair; $wq->wq_workers_start($ident, $jobs, $lei->oldset, { lei => $lei }); delete $lei->{pkt_op_p};