about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-03-20 19:04:05 +0900
committerEric Wong <e@80x24.org>2021-03-21 09:45:48 +0000
commitbcf5a733206b14f82cc151c702fd554cd08481ff (patch)
tree4963c40a5fa0fc51ce20bd89605d70c96d1f533f
parentb6829bbfd86f5d22a8ffb80fd7bfe59299fe6b55 (diff)
downloadpublic-inbox-bcf5a733206b14f82cc151c702fd554cd08481ff.tar.gz
Don't waste precious terminal space when there are only a small
number of possible keywords supported/reserved for JMAP.  In the
future, we may implement more sophisticated wrapping for labels,
but it we'll cross tha bridge when we come to it.
-rw-r--r--lib/PublicInbox/LeiOverview.pm5
-rw-r--r--t/lei-q-kw.t7
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/PublicInbox/LeiOverview.pm b/lib/PublicInbox/LeiOverview.pm
index 48237f8a..521bca50 100644
--- a/lib/PublicInbox/LeiOverview.pm
+++ b/lib/PublicInbox/LeiOverview.pm
@@ -176,7 +176,10 @@ sub _json_pretty {
                                         $pair =~ s/(null|"),"/$1, "/g;
                                         $pair;
                                 } @$v) . ']';
-                        } else { # references
+                        } elsif ($k eq 'kw') { # keywords are short, one-line
+                                $v = $json->encode($v);
+                                $v =~ s/","/", "/g;
+                        } else { # refs, labels, ...
                                 $v = '[' . join($sep, map {
                                         substr($json->encode([$_]), 1, -1);
                                 } @$v) . ']';
diff --git a/t/lei-q-kw.t b/t/lei-q-kw.t
index e7e14221..de2c775a 100644
--- a/t/lei-q-kw.t
+++ b/t/lei-q-kw.t
@@ -144,7 +144,7 @@ lei_ok(qw(q -o), "mboxrd:$o", "m:$m", @inc);
 # emulate MUA marking mboxrd message as unread
 open my $fh, '<', $o or BAIL_OUT;
 my $s = do { local $/; <$fh> };
-$s =~ s/^Status: OR\n/Status: O\nX-Status: A\n/sm or
+$s =~ s/^Status: OR\n/Status: O\nX-Status: AF\n/sm or
         fail "failed to clear R flag in $s";
 open $fh, '>', $o or BAIL_OUT;
 print $fh $s or BAIL_OUT;
@@ -156,7 +156,10 @@ lei_ok(qw(q -o), "mboxrd:$o", "m:$m", @inc);
 open $fh, '<', $o or BAIL_OUT;
 $s = do { local $/; <$fh> };
 like($s, qr/^Status: O\n/ms, 'seen keyword gone in mbox');
-like($s, qr/^X-Status: A\n/ms, 'answered flag set');
+like($s, qr/^X-Status: AF\n/ms, 'answered + flagged set');
 
+lei_ok(qw(q --pretty), "m:$m", @inc);
+like($lei_out, qr/^  "kw": \["answered", "flagged"\],\n/sm,
+        '--pretty JSON output shows kw: on one line');
 }); # test_lei
 done_testing;