about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiSavedSearch.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-04-13 10:54:46 +0000
committerEric Wong <e@80x24.org>2021-04-13 15:06:09 -0400
commit3052acd27f3119510b3efa33d77b610d6c4f1c85 (patch)
tree0e57051122af65f0802074b83c8752c87020f925 /lib/PublicInbox/LeiSavedSearch.pm
parent8ab43c1c27c725a8ef9307f5dba3e565169d48ca (diff)
downloadpublic-inbox-3052acd27f3119510b3efa33d77b610d6c4f1c85.tar.gz
The command isn't finalized, yet, but it's intended to update
an existing saved search.
Diffstat (limited to 'lib/PublicInbox/LeiSavedSearch.pm')
-rw-r--r--lib/PublicInbox/LeiSavedSearch.pm24
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/PublicInbox/LeiSavedSearch.pm b/lib/PublicInbox/LeiSavedSearch.pm
index ab9f393b..815008fd 100644
--- a/lib/PublicInbox/LeiSavedSearch.pm
+++ b/lib/PublicInbox/LeiSavedSearch.pm
@@ -17,18 +17,12 @@ use PublicInbox::Hval qw(to_filename);
 sub new {
         my ($cls, $lei, $dir) = @_;
         my $self = bless { ale => $lei->ale, -cfg => {} }, $cls;
-        if (defined $dir) { # updating existing saved search
+        if (defined $dir) { # updating existing saved search via "lei up"
                 my $f = $self->{'-f'} = "$dir/lei.saved-search";
                 -f $f && -r _ or
                         return $lei->fail("$f non-existent or unreadable");
                 $self->{-cfg} = PublicInbox::Config::git_config_dump($f);
-                my $q = $lei->{mset_opt}->{q_raw} = $self->{-cfg}->{'lei.q'} //
-                                        return $lei->fail("lei.q unset in $f");
-                my $lse = $lei->{lse} // die 'BUG: {lse} missing';
-                $lei->{mset_opt}->{qstr} = ref($q) ?
-                                $lse->query_argv_to_string($lse->git, $q) :
-                                $lse->query_approxidate($lse->git, $q);
-        } else { # new saved search
+        } else { # new saved search "lei q --save"
                 my $saved_dir = $lei->store_path . '/../saved-searches/';
                 my (@name) = ($lei->{ovv}->{dst} =~ m{([\w\-\.]+)/*\z});
                 push @name, to_filename($lei->{mset_opt}->{qstr});
@@ -42,6 +36,20 @@ sub new {
                 } else {
                         cfg_set($self, 'lei.q', $q);
                 }
+                my $fmt = $lei->{opt}->{'format'};
+                cfg_set($self, 'lei.q.format', $fmt) if defined $fmt;
+                cfg_set($self, 'lei.q.output', $lei->{opt}->{output});
+                for my $k (qw(only include exclude)) {
+                        my $ary = $lei->{opt}->{$k} // next;
+                        for my $x (@$ary) {
+                                cfg_set($self, '--add', "lei.q.$k", $x);
+                        }
+                }
+                for my $k (qw(external local remote import-remote
+                                import-before threads)) {
+                        my $val = $lei->{opt}->{$k} // next;
+                        cfg_set($self, "lei.q.$k", $val);
+                }
         }
         bless $self->{-cfg}, 'PublicInbox::Config';
         $self->{lock_path} = "$self->{-f}.flock";