From da49e774499e180b6f8eb2337b3087a6a32f9e5b Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sat, 16 Sep 2023 11:09:11 +0300 Subject: [PATCH] mu-info: add 'maildirs' topic For showing all maildirs under the root. --- man/mu-info.1.org | 1 + mu/mu-cmd-info.cc | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/man/mu-info.1.org b/man/mu-info.1.org index 1f68e00e..000f55f3 100644 --- a/man/mu-info.1.org +++ b/man/mu-info.1.org @@ -16,6 +16,7 @@ - *mu*: general mu build information (default) - *store*: information about the message store - *fields*: table with all the query fields and flags +- *maildirs*: list all maildirs under the store's root-maildir Note that while running (e.g. ~mu4e~), some of the ~store~ information can be delayed due to database caching. diff --git a/mu/mu-cmd-info.cc b/mu/mu-cmd-info.cc index 7550d9ff..7f082d10 100644 --- a/mu/mu-cmd-info.cc +++ b/mu/mu-cmd-info.cc @@ -219,6 +219,15 @@ topic_store(const Mu::Store& store, const Options& opts) return Ok(); } +static Result +topic_maildirs(const Mu::Store& store, const Options& opts) +{ + for (auto&& mdir: store.maildirs()) + mu_println("{}", mdir); + + return Ok(); +} + static Result topic_mu(const Options& opts) { @@ -227,10 +236,8 @@ topic_mu(const Options& opts) using namespace tabulate; info.add_row({"property", "value", "description"}); - info.add_row({"mu-version", std::string{VERSION}, - "Mu runtime version"}); - info.add_row({"xapian-version", Xapian::version_string(), - "Xapian runtime version"}); + info.add_row({"mu-version", std::string{VERSION}, "Mu runtime version"}); + info.add_row({"xapian-version", Xapian::version_string(), "Xapian runtime version"}); info.add_row({"gmime-version", mu_format("{}.{}.{}", gmime_major_version, gmime_minor_version, gmime_micro_version), "GMime runtime version"}); @@ -281,6 +288,8 @@ Mu::mu_cmd_info(const Mu::Store& store, const Options& opts) const auto topic{opts.info.topic}; if (topic == "store") return topic_store(store, opts); + else if (topic == "maildirs") + return topic_maildirs(store, opts); else if (topic == "fields") { topic_fields(opts); std::cout << std::endl; @@ -298,8 +307,9 @@ Mu::mu_cmd_info(const Mu::Store& store, const Options& opts) col.fg(Color::Green), t, col.reset(), d); }; - mu_println("\nother info topics ('mu info '):\n{}\n{}", + mu_println("\nother info topics ('mu info '):\n{}\n{}\n{}", topic("store", "information about the message store (database)"), + topic("maildirs", "list the maildirs under the store's root-maildir"), topic("fields", "information about message fields")); }