]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LEI.pm
lei config --edit: use controlling terminal
[public-inbox.git] / lib / PublicInbox / LEI.pm
index 8b0614f27980f8e4e53f31681562ae25cc83b119..148a5b1e530d00e0ab73d02aa0f214532d28ac0b 100644 (file)
@@ -40,7 +40,6 @@ $GLP_PASS->configure(qw(gnu_getopt no_ignore_case auto_abbrev pass_through));
 
 our %PATH2CFG; # persistent for socket daemon
 our $MDIR2CFGPATH; # /path/to/maildir => { /path/to/config => [ ino watches ] }
-our %LIVE_SOCK; # "GLOB(0x....)" => $lei->{sock}
 
 # TBD: this is a documentation mechanism to show a subcommand
 # (may) pass options through to another command:
@@ -215,7 +214,7 @@ our %CMD = ( # sorted in order of importance/use:
 'ls-mail-sync' => [ '[FILTER]', 'list mail sync folders',
                qw(z|0 globoff|g invert-match|v local remote), @c_opt ],
 'ls-mail-source' => [ 'URL', 'list IMAP or NNTP mail source folders',
-               qw(z|0 ascii l url), @c_opt ],
+               qw(z|0 ascii l pretty url), @c_opt ],
 'forget-external' => [ 'LOCATION...|--prune',
        'exclude further results from a publicinbox|extindex',
        qw(prune), @c_opt ],
@@ -279,7 +278,7 @@ our %CMD = ( # sorted in order of importance/use:
 'config' => [ '[...]', sub {
                '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') ],
+        qw(edit|e c=s@ C=s@), pass_through('git config') ],
 'inspect' => [ 'ITEMS...|--stdin', 'inspect lei/store and/or local external',
        qw(stdin| pretty ascii dir=s), @c_opt ],
 
@@ -580,7 +579,6 @@ sub _lei_atfork_child {
        $dir_idle->force_close if $dir_idle;
        %PATH2CFG = ();
        $MDIR2CFGPATH = {};
-       %LIVE_SOCK = ();
        eval 'no warnings; undef $PublicInbox::LeiNoteEvent::to_flush';
        undef $errors_log;
        $quit = \&CORE::exit;
@@ -619,7 +617,6 @@ sub pkt_ops {
        $ops->{x_it} = [ \&x_it, $lei ];
        $ops->{child_error} = [ \&child_error, $lei ];
        $ops->{incr} = [ \&incr, $lei ];
-       $ops->{sto_done_request} = [ \&sto_done_request, $lei, $lei->{sock} ];
        $ops;
 }
 
@@ -630,7 +627,6 @@ sub workers_start {
        my $end = $lei->pkt_op_pair;
        my $ident = $wq->{-wq_ident} // "lei-$lei->{cmd} worker";
        $flds->{lei} = $lei;
-       $wq->{-wq_nr_workers} //= $jobs; # lock, no incrementing
        $wq->wq_workers_start($ident, $jobs, $lei->oldset, $flds);
        delete $lei->{pkt_op_p};
        my $op_c = delete $lei->{pkt_op_c};
@@ -874,14 +870,6 @@ sub _config {
        waitpid(spawn($cmd, \%env, \%rdr), 0);
 }
 
-sub lei_config {
-       my ($self, @argv) = @_;
-       $self->{opt}->{'config-file'} and return fail $self,
-               "config file switches not supported by `lei config'";
-       _config(@_);
-       x_it($self, $?) if $?;
-}
-
 sub lei_daemon_pid { puts shift, $$ }
 
 sub lei_daemon_kill {
@@ -1496,22 +1484,24 @@ sub lms {
        (-f $f || $rw) ? PublicInbox::LeiMailSync->new($f) : undef;
 }
 
-sub sto_done_request { # only call this from lei-daemon process (not workers)
+sub sto_done_request {
        my ($lei, $sock) = @_;
        eval {
                if ($sock //= $lei->{sock}) { # issue, async wait
-                       $LIVE_SOCK{"$sock"} = $sock;
-                       $lei->{sto}->ipc_do('done', "$sock");
+                       $lei->{sto}->wq_io_do('done', [ $sock ]);
                } else { # forcibly wait
-                       my $wait = $lei->{sto}->ipc_do('done');
+                       my $wait = $lei->{sto}->wq_do('done');
                }
        };
        $lei->err($@) if $@;
 }
 
-sub sto_done_complete { # called in lei-daemon when LeiStore->done is complete
-       my ($sock_str) = @_;
-       delete $LIVE_SOCK{$sock_str}; # frees {sock} for waiting lei clients
+sub cfg_dump ($$) {
+       my ($lei, $f) = @_;
+       my $ret = eval { PublicInbox::Config->git_config_dump($f, $lei->{2}) };
+       return $ret if !$@;
+       $lei->err($@);
+       undef;
 }
 
 1;