mu: implement init, info commands

'init' is for the inital database setup

'info' is for gettting information about the mu database.
This commit is contained in:
Dirk-Jan C. Binnema
2020-02-06 20:22:43 +02:00
parent 2575b2d0e3
commit f51846eefc
13 changed files with 363 additions and 355 deletions

View File

@ -1396,3 +1396,44 @@ mu_store_get_dirstamp (const MuStore *store, const char *dirpath, GError **err)
}
void
mu_store_print_info (const MuStore *store, gboolean nocolor)
{
const auto green{nocolor ? "" : MU_COLOR_GREEN};
const auto def{nocolor ? "" : MU_COLOR_DEFAULT};
std::cout << "database-path : "
<< green << self(store)->database_path() << def << "\n"
<< "messages in store : "
<< green << self(store)->size() << def << "\n"
<< "schema-version : "
<< green << self(store)->schema_version() << def << "\n";
const auto created{mu_store_created (store)};
const auto tstamp{localtime (&created)};
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-y2k"
char tbuf[32];
strftime (tbuf, sizeof(tbuf), "%c", tstamp);
#pragma GCC diagnostic pop
std::cout << "created : " << green << tbuf << def << "\n"
<< "maildir : "
<< green << self(store)->root_maildir() << def << "\n";
std::cout << ("personal-addresses : ");
auto addrs{mu_store_personal_addresses (store)};
if (!addrs || g_strv_length(addrs) == 0)
std::cout << green << "<none>" << def << "\n";
else {
for (auto i = 0U; addrs[i]; ++i) {
std::cout << (i != 0 ? " " : "")
<< green << addrs[i] << def << "\n";
}
}
g_strfreev(addrs);
}