diff --git a/man/mu-find.1.org b/man/mu-find.1.org index 14a89ee3..0296aa63 100644 --- a/man/mu-find.1.org +++ b/man/mu-find.1.org @@ -79,7 +79,7 @@ parameters, such as: m *m*aildir #+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 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) #+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: @@ -283,4 +283,4 @@ default format), and UTF-8 for all other formats (=sexp=, =xml=). * SEE ALSO -*mu(1)*, *mu-index(1)*, *mu-query(7)*, *mu-fields(1)* +*mu(1)*, *mu-index(1)*, *mu-query(7)*, *mu-info(1)* diff --git a/man/mu-query.7.org b/man/mu-query.7.org index d44a59a3..fe5c06bf 100644 --- a/man/mu-query.7.org +++ b/man/mu-query.7.org @@ -114,7 +114,8 @@ bit longer than 'normal' queries. * FIELDS 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 | @@ -325,7 +326,7 @@ hallo and (lang:nl or lang:de) 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 -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 e.g. to Maildirs that have spaces in their name, such as =Sent Items=. See *MAILDIR* @@ -335,4 +336,4 @@ above. * SEE ALSO -*mu-find(1)*, *mu-fields(1), *pcre(3)* +*mu-find(1)*, *mu-info(1), *pcre(3)* diff --git a/mu/mu-cmd-info.cc b/mu/mu-cmd-info.cc index bc94086f..65d543f5 100644 --- a/mu/mu-cmd-info.cc +++ b/mu/mu-cmd-info.cc @@ -22,24 +22,73 @@ #include "mu-cmd.hh" #include #include "utils/mu-utils.hh" +#include #include using namespace Mu; using namespace tabulate; +template <> struct fmt::formatter : ostream_formatter {}; + 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; - (*table.begin()).format() - .font_style({FontStyle::bold}) - .font_color(Color::blue); + for (auto&& c = 0U; c != table.row(0).size(); ++c) { + switch (c) { + 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 topic_fields(const Options& opts) { @@ -75,9 +124,9 @@ topic_fields(const Options& opts) if (field.is_internal()) return; // skip. - fields.add_row({format("%.*s", STR_V(field.name)), - field.alias.empty() ? "" : format("%.*s", STR_V(field.alias)), - field.shortcut ? format("%c", field.shortcut) : ""s, + fields.add_row({mu_format("{}", field.name), + field.alias.empty() ? "" : mu_format("{}", field.alias), + field.shortcut ? mu_format("{}", field.shortcut) : ""s, searchable(field), field.is_value() ? "yes" : "no", field.include_in_sexp() ? "yes" : "no", @@ -86,8 +135,7 @@ topic_fields(const Options& opts) ++row; }); - table_header(fields, opts); - + colorify(fields, opts); std::cout << fields << '\n'; return Ok(); @@ -120,38 +168,23 @@ topic_flags(const Options& opts) } }, info.category); - flags.add_row({format("%.*s", STR_V(info.name)), - format("%c", info.shortcut), + flags.add_row({mu_format("{}", info.name), + mu_format("{}", info.shortcut), catname, std::string{info.description}}); }); - table_header(flags, opts); + colorify(flags, opts); std::cout << flags << '\n'; + + 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 topic_store(const Mu::Store& store, const Options& opts) { - using namespace tabulate; - auto tstamp = [](::time_t t)->std::string { if (t == 0) return "never"; @@ -161,12 +194,13 @@ topic_store(const Mu::Store& store, const Options& opts) Table info; const auto conf{store.config()}; + info.add_row({"property", "value"}); info.add_row({"maildir", store.root_maildir()}); info.add_row({"database-path", store.path()}); info.add_row({"schema-version", - format("%zu", conf.get())}); - info.add_row({"max-message-size", format("%zu", conf.get())}); - info.add_row({"batch-size", format("%zu", conf.get())}); + mu_format("{}", conf.get())}); + info.add_row({"max-message-size", mu_format("{}", conf.get())}); + info.add_row({"batch-size", mu_format("{}", conf.get())}); info.add_row({"created", tstamp(conf.get())}); for (auto&& c : conf.get()) @@ -174,12 +208,12 @@ topic_store(const Mu::Store& store, const Options& opts) for (auto&& c : conf.get()) 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-index", tstamp(store.statistics().last_index)}); if (!opts.nocolor) - colorify(info); + colorify(info, opts); std::cout << info << '\n'; @@ -187,22 +221,23 @@ topic_store(const Mu::Store& store, const Options& opts) } static Result -topic_common(const Options& opts) +topic_mu(const Options& opts) { Table info; using namespace tabulate; - info.add_row({"mu version", std::string{VERSION}}); - info.add_row({"store schema-version", format("%u", MU_STORE_SCHEMA_VERSION)}); - info.add_row({"guile-support:", + info.add_row({"property", "value"}); + info.add_row({"version", std::string{VERSION}}); + info.add_row({"schema-version", mu_format("{}", MU_STORE_SCHEMA_VERSION)}); + info.add_row({"guile-support", #if BUILD_GUILE "yes" #else "no" #endif }); - info.add_row({"readline-support:", + info.add_row({"readline-support", #if HAVE_LIBREADLINE "yes" #else @@ -210,7 +245,7 @@ topic_common(const Options& opts) #endif }); - info.add_row({"cld2 language support:", + info.add_row({"cld2-support", #if HAVE_CLD2 "yes" #else @@ -219,10 +254,12 @@ topic_common(const Options& opts) }); if (!opts.nocolor) - colorify(info); + colorify(info, opts); std::cout << info << '\n'; + // mu_println("{}", info); + return Ok(); } @@ -239,21 +276,22 @@ Mu::mu_cmd_info(const Mu::Store& store, const Options& opts) else if (topic == "fields") { topic_fields(opts); return topic_flags(opts); - } else if (topic == "common") { - return topic_common(opts); + } else if (topic == "mu") { + return topic_mu(opts); } else { - topic_common(opts); + topic_store(store, opts); MaybeAnsi col{!opts.nocolor}; using Color = MaybeAnsi::Color; - auto topic = [&](const std::string& s)->std::string { - return " " + col.fg(Color::Green) + s.c_str() + col.reset(); + auto topic = [&](auto&& t, auto&& d)->std::string { + return mu_format("{}{:<10}{} - {:>12}", + col.fg(Color::Green), t, col.reset(), d); }; - std::cout << "\nother available info topics ('mu info '):\n" - << topic("store") << " - information about the message store (database)\n" - << topic("fields") << " - information about message fields\n"; + mu_println("\nother info topics ('mu info '):\n{}\n{}", + topic("store", "information about the message store (database)"), + topic("fields", "information about message fields")); } return Ok(); diff --git a/mu/mu-cmd.cc b/mu/mu-cmd.cc index aa9982ee..8b56f839 100644 --- a/mu/mu-cmd.cc +++ b/mu/mu-cmd.cc @@ -48,9 +48,7 @@ static Result cmd_fields(const Options& opts) { mu_printerrln("the 'mu fields' command has been superseded by 'mu info'; try:\n" - " mu info fields\n" - " mu info flags"); - + " mu info fields\n"); return Ok(); }