X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FLEI.pm;h=39278de640a0ab9004597d281ae3484caa18b140;hb=b6b86cfd238c170ea3e2c4d4179f06c7af139086;hp=9f49fc038c8881fad6a7a44a988f2e0ccf5f47e3;hpb=7dd4d590e1d5e12b2b767122aeec66124a10acb1;p=public-inbox.git diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 9f49fc03..39278de6 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} // @@ -193,7 +200,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 +212,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 ],