mu-cmd-find: Fix links ouput

Special case the footer/header for the links output. Small code
cleanups.

Fix error in docs.

Fixes: #2035.
This commit is contained in:
Dirk-Jan C. Binnema 2021-06-11 10:40:01 +03:00
parent 047c10453a
commit 9020389a56
2 changed files with 25 additions and 23 deletions

View File

@ -1,4 +1,4 @@
.TH MU FIND 1 "12 February 2021" "User Manuals"
.TH MU FIND 1 "22 June 2021" "User Manuals"
.SH NAME
@ -74,17 +74,17 @@ The table of replacement characters is superset of the list mentions for
search parameters; the complete list:
.nf
t \fBt\fRo: recipient
c \fBc\fRc: (carbon-copy) recipient
h Bcc: (blind carbon-copy, \fBh\fRidden) recipient
d Sent \fBd\fRate of the message
f Message sender (\fBf\fRrom:)
g Message flags (fla\fBg\fRs)
l Full path to the message (\fBl\fRocation)
p Message \fBp\fRriority (high, normal, low)
s Message \fBs\fRubject
i Message-\fBi\fRd
m \fBm\fRaildir
t \fBt\fRo: recipient
c \fBc\fRc: (carbon-copy) recipient
h Bcc: (blind carbon-copy, \fBh\fRidden) recipient
d Sent \fBd\fRate of the message
f Message sender (\fBf\fRrom:)
g Message flags (fla\fBg\fRs)
l Full path to the message (\fBl\fRocation)
p Message \fBp\fRriority (high, normal, low)
s Message \fBs\fRubject
i Message-\fBi\fRd
m \fBm\fRaildir
v Mailing-list Id
.fi
@ -162,7 +162,7 @@ same maildir. However, this option will delete any symlink it finds,
so be careful.
.nf
$ mu find grolsch --linksdir=~/Maildir/search --clearlinks
$ mu find grolsch --format=links --linksdir=~/Maildir/search --clearlinks
.fi
will store links to found messages in \fI~/Maildir/search\fR. If the directory

View File

@ -45,8 +45,8 @@ using namespace Mu;
struct OutputInfo{
Xapian::docid docid{};
bool is_first{};
bool is_last{};
bool header{};
bool footer{};
Option<QueryMatch&> match_info;
};
@ -231,8 +231,10 @@ static bool
output_link (MuMsg *msg, const OutputInfo& info,
const MuConfig *opts, GError **err)
{
if (info.is_first && !prepare_links (opts, err))
return FALSE;
if (info.header)
return prepare_links (opts, err);
else if (info.footer)
return true;
return mu_maildir_link (mu_msg_get_path (msg),
opts->linksdir, err);
@ -510,12 +512,12 @@ output_sexp (MuMsg *msg, const OutputInfo& info, const MuConfig *opts, GError **
static bool
output_json (MuMsg *msg, const OutputInfo& info, const MuConfig *opts, GError **err)
{
if (info.is_first) {
if (info.header) {
g_print ("[\n");
return true;
}
if (info.is_last) {
if (info.footer) {
g_print("]\n");
return true;
}
@ -542,13 +544,13 @@ print_attr_xml (const char* elm, const char *str)
static bool
output_xml (MuMsg *msg, const OutputInfo& info, const MuConfig *opts, GError **err)
{
if (info.is_first) {
if (info.header) {
g_print ("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
g_print ("<messages>\n");
return true;
}
if (info.is_last) {
if (info.footer) {
g_print ("</messages>\n");
return true;
}
@ -594,7 +596,7 @@ output_query_results (const QueryResults& qres, const MuConfig *opts, GError **e
return false;
gboolean rv{true};
output_func (NULL, FirstOutput, NULL, NULL);
output_func (NULL, FirstOutput, opts, NULL);
for (auto&& item: qres) {
@ -610,7 +612,7 @@ output_query_results (const QueryResults& qres, const MuConfig *opts, GError **e
if (!rv)
break;
}
output_func (NULL, LastOutput, NULL, NULL);
output_func (NULL, LastOutput, opts, NULL);
return rv;
}