mu: refactor labels code

Split labels-cache and store-labels.
This commit is contained in:
Dirk-Jan C. Binnema
2025-09-02 23:19:54 +03:00
committed by Seth Ladygo
parent 152182a567
commit 3a12c69b10
11 changed files with 256 additions and 188 deletions

View File

@ -23,6 +23,8 @@
#include <string_view>
#include "mu-store.hh"
#include "mu-store-labels.hh"
#include "message/mu-message.hh"
#include "message/mu-labels.hh"
@ -118,8 +120,9 @@ label_list(Mu::Store& store, const Options& opts)
if (opts.label.restore) {
if (!opts.quiet)
mu_println("labels: restoring list from store...");
if (const auto res = store.restore_label_map(); !res)
if (const auto res = store.restore_label_map(); !res) {
return res;
}
}
for (const auto& [label, n]: store.label_map())

View File

@ -556,7 +556,7 @@ sub_label(CLI::App& sub, Options& opts)
sub.final_callback([&](){
if (sub.got_subcommand("list")) {
opts.label.sub = Options::Label::Sub::List;
opts.label.read_only = true;
opts.label.read_only = opts.label.restore ? false : true;
} else if (sub.got_subcommand("clear")) {
opts.label.sub = Options::Label::Sub::Clear;
opts.label.read_only = opts.label.dry_run;