mirror of https://github.com/djcb/mu.git
mu-info: improve docs; better colors
This commit is contained in:
parent
c59d493296
commit
d96e9cc4ba
|
@ -79,7 +79,7 @@ parameters, such as:
|
||||||
m *m*aildir
|
m *m*aildir
|
||||||
#+end_example
|
#+end_example
|
||||||
|
|
||||||
For the complate list, see *mu-fields(1)*.
|
For the complete list, try the command: ~mu info fields~.
|
||||||
|
|
||||||
The message flags are described in *mu-query(7)*. As an example, a message which
|
The message flags are described in *mu-query(7)*. As an example, a message which
|
||||||
is 'seen', has an attachment and is signed would have 'asz' as its corresponding
|
is 'seen', has an attachment and is signed would have 'asz' as its corresponding
|
||||||
|
@ -100,7 +100,7 @@ specify the field to sort the search results by and the direction (i.e.,
|
||||||
to,t To:-recipient(s)
|
to,t To:-recipient(s)
|
||||||
#+end_example
|
#+end_example
|
||||||
|
|
||||||
For the complete list use can use the *mu fields* command; see *mu-fields(1)*.
|
For the complete list, try the command: ~mu info fields~.
|
||||||
|
|
||||||
Thus, for example, to sort messages by date, you could specify:
|
Thus, for example, to sort messages by date, you could specify:
|
||||||
|
|
||||||
|
@ -283,4 +283,4 @@ default format), and UTF-8 for all other formats (=sexp=, =xml=).
|
||||||
|
|
||||||
* SEE ALSO
|
* SEE ALSO
|
||||||
|
|
||||||
*mu(1)*, *mu-index(1)*, *mu-query(7)*, *mu-fields(1)*
|
*mu(1)*, *mu-index(1)*, *mu-query(7)*, *mu-info(1)*
|
||||||
|
|
|
@ -114,7 +114,8 @@ bit longer than 'normal' queries.
|
||||||
* FIELDS
|
* FIELDS
|
||||||
|
|
||||||
We already saw a number of search fields, such as *subject:* and *body:*. For the
|
We already saw a number of search fields, such as *subject:* and *body:*. For the
|
||||||
full table with all details, including single-char shortcuts, see *mu-fields(1)*.
|
full table with all details, including single-char shortcuts, try the command:
|
||||||
|
~mu info fields~.
|
||||||
|
|
||||||
|------------+-----------+--------------------------------|
|
|------------+-----------+--------------------------------|
|
||||||
| field-name | alias | description |
|
| field-name | alias | description |
|
||||||
|
@ -325,7 +326,7 @@ hallo and (lang:nl or lang:de)
|
||||||
|
|
||||||
With current Xapian versions, the apostroph character is considered part of a
|
With current Xapian versions, the apostroph character is considered part of a
|
||||||
word. Thus, you cannot find =D'Artagnan= by searching for =Artagnan=. So, include
|
word. Thus, you cannot find =D'Artagnan= by searching for =Artagnan=. So, include
|
||||||
the apostroph in search or use a regexp search.
|
the apostrophe in search or use a regexp search.
|
||||||
|
|
||||||
Matching on spaces has changed compared to the old query-parser; this applies
|
Matching on spaces has changed compared to the old query-parser; this applies
|
||||||
e.g. to Maildirs that have spaces in their name, such as =Sent Items=. See *MAILDIR*
|
e.g. to Maildirs that have spaces in their name, such as =Sent Items=. See *MAILDIR*
|
||||||
|
@ -335,4 +336,4 @@ above.
|
||||||
|
|
||||||
* SEE ALSO
|
* SEE ALSO
|
||||||
|
|
||||||
*mu-find(1)*, *mu-fields(1), *pcre(3)*
|
*mu-find(1)*, *mu-info(1), *pcre(3)*
|
||||||
|
|
|
@ -22,24 +22,73 @@
|
||||||
#include "mu-cmd.hh"
|
#include "mu-cmd.hh"
|
||||||
#include <message/mu-message.hh>
|
#include <message/mu-message.hh>
|
||||||
#include "utils/mu-utils.hh"
|
#include "utils/mu-utils.hh"
|
||||||
|
#include <fmt/ostream.h>
|
||||||
|
|
||||||
#include <thirdparty/tabulate.hpp>
|
#include <thirdparty/tabulate.hpp>
|
||||||
|
|
||||||
using namespace Mu;
|
using namespace Mu;
|
||||||
using namespace tabulate;
|
using namespace tabulate;
|
||||||
|
|
||||||
|
template <> struct fmt::formatter<Table> : ostream_formatter {};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
table_header(Table& table, const Options& opts)
|
colorify(Table& table, const Options& opts)
|
||||||
{
|
{
|
||||||
if (opts.nocolor)
|
if (opts.nocolor || table.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
(*table.begin()).format()
|
for (auto&& c = 0U; c != table.row(0).size(); ++c) {
|
||||||
.font_style({FontStyle::bold})
|
switch (c) {
|
||||||
.font_color(Color::blue);
|
case 0:
|
||||||
|
table.column(c).format()
|
||||||
|
.font_color(Color::green)
|
||||||
|
.font_style({FontStyle::bold});
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
table.column(c).format()
|
||||||
|
.font_color(Color::blue);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
table.column(c).format()
|
||||||
|
.font_color(Color::magenta);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
table.column(c).format()
|
||||||
|
.font_color(Color::yellow);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
table.column(c).format()
|
||||||
|
.font_color(Color::green);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
table.column(c).format()
|
||||||
|
.font_color(Color::blue);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
table.column(c).format()
|
||||||
|
.font_color(Color::magenta);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 7:
|
||||||
|
table.column(c).format()
|
||||||
|
.font_color(Color::yellow);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
table.column(c).format()
|
||||||
|
.font_color(Color::grey);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto&& c = 0U; c != table.row(0).size(); ++c)
|
||||||
|
table[0][c].format()
|
||||||
|
.font_color(Color::white)
|
||||||
|
.font_style({FontStyle::bold});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Result<void>
|
static Result<void>
|
||||||
topic_fields(const Options& opts)
|
topic_fields(const Options& opts)
|
||||||
{
|
{
|
||||||
|
@ -75,9 +124,9 @@ topic_fields(const Options& opts)
|
||||||
if (field.is_internal())
|
if (field.is_internal())
|
||||||
return; // skip.
|
return; // skip.
|
||||||
|
|
||||||
fields.add_row({format("%.*s", STR_V(field.name)),
|
fields.add_row({mu_format("{}", field.name),
|
||||||
field.alias.empty() ? "" : format("%.*s", STR_V(field.alias)),
|
field.alias.empty() ? "" : mu_format("{}", field.alias),
|
||||||
field.shortcut ? format("%c", field.shortcut) : ""s,
|
field.shortcut ? mu_format("{}", field.shortcut) : ""s,
|
||||||
searchable(field),
|
searchable(field),
|
||||||
field.is_value() ? "yes" : "no",
|
field.is_value() ? "yes" : "no",
|
||||||
field.include_in_sexp() ? "yes" : "no",
|
field.include_in_sexp() ? "yes" : "no",
|
||||||
|
@ -86,8 +135,7 @@ topic_fields(const Options& opts)
|
||||||
++row;
|
++row;
|
||||||
});
|
});
|
||||||
|
|
||||||
table_header(fields, opts);
|
colorify(fields, opts);
|
||||||
|
|
||||||
std::cout << fields << '\n';
|
std::cout << fields << '\n';
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
|
@ -120,38 +168,23 @@ topic_flags(const Options& opts)
|
||||||
}
|
}
|
||||||
}, info.category);
|
}, info.category);
|
||||||
|
|
||||||
flags.add_row({format("%.*s", STR_V(info.name)),
|
flags.add_row({mu_format("{}", info.name),
|
||||||
format("%c", info.shortcut),
|
mu_format("{}", info.shortcut),
|
||||||
catname,
|
catname,
|
||||||
std::string{info.description}});
|
std::string{info.description}});
|
||||||
});
|
});
|
||||||
|
|
||||||
table_header(flags, opts);
|
colorify(flags, opts);
|
||||||
|
|
||||||
std::cout << flags << '\n';
|
std::cout << flags << '\n';
|
||||||
|
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
colorify(Table& table)
|
|
||||||
{
|
|
||||||
for (auto&& row: table) {
|
|
||||||
|
|
||||||
if (row.cells().size() < 2)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
row.cells().at(0)->format().font_style({FontStyle::bold})
|
|
||||||
.font_color(Color::green);
|
|
||||||
row.cells().at(1)->format().font_color(Color::blue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static Result<void>
|
static Result<void>
|
||||||
topic_store(const Mu::Store& store, const Options& opts)
|
topic_store(const Mu::Store& store, const Options& opts)
|
||||||
{
|
{
|
||||||
using namespace tabulate;
|
|
||||||
|
|
||||||
auto tstamp = [](::time_t t)->std::string {
|
auto tstamp = [](::time_t t)->std::string {
|
||||||
if (t == 0)
|
if (t == 0)
|
||||||
return "never";
|
return "never";
|
||||||
|
@ -161,12 +194,13 @@ topic_store(const Mu::Store& store, const Options& opts)
|
||||||
|
|
||||||
Table info;
|
Table info;
|
||||||
const auto conf{store.config()};
|
const auto conf{store.config()};
|
||||||
|
info.add_row({"property", "value"});
|
||||||
info.add_row({"maildir", store.root_maildir()});
|
info.add_row({"maildir", store.root_maildir()});
|
||||||
info.add_row({"database-path", store.path()});
|
info.add_row({"database-path", store.path()});
|
||||||
info.add_row({"schema-version",
|
info.add_row({"schema-version",
|
||||||
format("%zu", conf.get<Config::Id::SchemaVersion>())});
|
mu_format("{}", conf.get<Config::Id::SchemaVersion>())});
|
||||||
info.add_row({"max-message-size", format("%zu", conf.get<Config::Id::MaxMessageSize>())});
|
info.add_row({"max-message-size", mu_format("{}", conf.get<Config::Id::MaxMessageSize>())});
|
||||||
info.add_row({"batch-size", format("%zu", conf.get<Config::Id::BatchSize>())});
|
info.add_row({"batch-size", mu_format("{}", conf.get<Config::Id::BatchSize>())});
|
||||||
info.add_row({"created", tstamp(conf.get<Config::Id::Created>())});
|
info.add_row({"created", tstamp(conf.get<Config::Id::Created>())});
|
||||||
|
|
||||||
for (auto&& c : conf.get<Config::Id::PersonalAddresses>())
|
for (auto&& c : conf.get<Config::Id::PersonalAddresses>())
|
||||||
|
@ -174,12 +208,12 @@ topic_store(const Mu::Store& store, const Options& opts)
|
||||||
for (auto&& c : conf.get<Config::Id::IgnoredAddresses>())
|
for (auto&& c : conf.get<Config::Id::IgnoredAddresses>())
|
||||||
info.add_row({"ignored-address", c});
|
info.add_row({"ignored-address", c});
|
||||||
|
|
||||||
info.add_row({"messages in store", format("%zu", store.size())});
|
info.add_row({"messages in store", mu_format("{}", store.size())});
|
||||||
info.add_row({"last-change", tstamp(store.statistics().last_change)});
|
info.add_row({"last-change", tstamp(store.statistics().last_change)});
|
||||||
info.add_row({"last-index", tstamp(store.statistics().last_index)});
|
info.add_row({"last-index", tstamp(store.statistics().last_index)});
|
||||||
|
|
||||||
if (!opts.nocolor)
|
if (!opts.nocolor)
|
||||||
colorify(info);
|
colorify(info, opts);
|
||||||
|
|
||||||
std::cout << info << '\n';
|
std::cout << info << '\n';
|
||||||
|
|
||||||
|
@ -187,22 +221,23 @@ topic_store(const Mu::Store& store, const Options& opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result<void>
|
static Result<void>
|
||||||
topic_common(const Options& opts)
|
topic_mu(const Options& opts)
|
||||||
{
|
{
|
||||||
Table info;
|
Table info;
|
||||||
|
|
||||||
using namespace tabulate;
|
using namespace tabulate;
|
||||||
|
|
||||||
info.add_row({"mu version", std::string{VERSION}});
|
info.add_row({"property", "value"});
|
||||||
info.add_row({"store schema-version", format("%u", MU_STORE_SCHEMA_VERSION)});
|
info.add_row({"version", std::string{VERSION}});
|
||||||
info.add_row({"guile-support:",
|
info.add_row({"schema-version", mu_format("{}", MU_STORE_SCHEMA_VERSION)});
|
||||||
|
info.add_row({"guile-support",
|
||||||
#if BUILD_GUILE
|
#if BUILD_GUILE
|
||||||
"yes"
|
"yes"
|
||||||
#else
|
#else
|
||||||
"no"
|
"no"
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
info.add_row({"readline-support:",
|
info.add_row({"readline-support",
|
||||||
#if HAVE_LIBREADLINE
|
#if HAVE_LIBREADLINE
|
||||||
"yes"
|
"yes"
|
||||||
#else
|
#else
|
||||||
|
@ -210,7 +245,7 @@ topic_common(const Options& opts)
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
|
|
||||||
info.add_row({"cld2 language support:",
|
info.add_row({"cld2-support",
|
||||||
#if HAVE_CLD2
|
#if HAVE_CLD2
|
||||||
"yes"
|
"yes"
|
||||||
#else
|
#else
|
||||||
|
@ -219,10 +254,12 @@ topic_common(const Options& opts)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!opts.nocolor)
|
if (!opts.nocolor)
|
||||||
colorify(info);
|
colorify(info, opts);
|
||||||
|
|
||||||
std::cout << info << '\n';
|
std::cout << info << '\n';
|
||||||
|
|
||||||
|
// mu_println("{}", info);
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,21 +276,22 @@ Mu::mu_cmd_info(const Mu::Store& store, const Options& opts)
|
||||||
else if (topic == "fields") {
|
else if (topic == "fields") {
|
||||||
topic_fields(opts);
|
topic_fields(opts);
|
||||||
return topic_flags(opts);
|
return topic_flags(opts);
|
||||||
} else if (topic == "common") {
|
} else if (topic == "mu") {
|
||||||
return topic_common(opts);
|
return topic_mu(opts);
|
||||||
} else {
|
} else {
|
||||||
topic_common(opts);
|
topic_store(store, opts);
|
||||||
|
|
||||||
MaybeAnsi col{!opts.nocolor};
|
MaybeAnsi col{!opts.nocolor};
|
||||||
using Color = MaybeAnsi::Color;
|
using Color = MaybeAnsi::Color;
|
||||||
|
|
||||||
auto topic = [&](const std::string& s)->std::string {
|
auto topic = [&](auto&& t, auto&& d)->std::string {
|
||||||
return " " + col.fg(Color::Green) + s.c_str() + col.reset();
|
return mu_format("{}{:<10}{} - {:>12}",
|
||||||
|
col.fg(Color::Green), t, col.reset(), d);
|
||||||
};
|
};
|
||||||
|
|
||||||
std::cout << "\nother available info topics ('mu info <topic>'):\n"
|
mu_println("\nother info topics ('mu info <topic>'):\n{}\n{}",
|
||||||
<< topic("store") << " - information about the message store (database)\n"
|
topic("store", "information about the message store (database)"),
|
||||||
<< topic("fields") << " - information about message fields\n";
|
topic("fields", "information about message fields"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
|
|
|
@ -48,9 +48,7 @@ static Result<void>
|
||||||
cmd_fields(const Options& opts)
|
cmd_fields(const Options& opts)
|
||||||
{
|
{
|
||||||
mu_printerrln("the 'mu fields' command has been superseded by 'mu info'; try:\n"
|
mu_printerrln("the 'mu fields' command has been superseded by 'mu info'; try:\n"
|
||||||
" mu info fields\n"
|
" mu info fields\n");
|
||||||
" mu info flags");
|
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue