cfind: rework, add support for json output

Update the old cfind code, and add json output support while doing so.
This commit is contained in:
Dirk-Jan C. Binnema
2022-12-29 19:05:22 +02:00
parent 2229e2e77e
commit 5300b7ce82
5 changed files with 351 additions and 374 deletions

View File

@ -167,30 +167,14 @@ sub_cfind(CLI::App& sub, Options& opts)
{
using Format = Options::Cfind::Format;
static constexpr InfoEnum<Format, 8> FormatInfos = {{
{ Format::Plain,
{"plain", "Plain output"}
},
{ Format::MuttAlias,
{"mutt-alias", "Mutt alias"}
},
{ Format::MuttAddressBook,
{"mutt-ab", "Mutt address book"}
},
{ Format::Wanderlust,
{"wl", "Wanderlust"}
},
{ Format::OrgContact,
{"org-contact", "org-contact"}
},
{ Format::Bbdb,
{"bbdb", "BBDB"}
},
{ Format::Csv,
{"csv", "comma-separated values"}
},
{ Format::Debug,
{"debug", "debug output"}
}
{ Format::Plain, {"plain", "Plain output"} },
{ Format::MuttAlias, {"mutt-alias", "Mutt alias"} },
{ Format::MuttAddressBook, {"mutt-ab", "Mutt address book"}},
{ Format::Wanderlust, {"wl", "Wanderlust"}},
{ Format::OrgContact, {"org-contact", "org-contact"}},
{ Format::Bbdb, {"bbdb", "Emacs BBDB"}},
{ Format::Csv, {"csv", "comma-separated values"}},
{ Format::Json, {"json", "format as json array"}},
}};
const auto fhelp = options_help(FormatInfos, Format::Plain);
@ -205,10 +189,8 @@ sub_cfind(CLI::App& sub, Options& opts)
sub.add_option("pattern", opts.cfind.rx_pattern,
"Regular expression pattern to match");
sub.add_flag("--personal,-p", opts.cfind.personal,
"Only show 'personal' contacts");
sub.add_option("--maxnum,-n", opts.cfind.maxnum,
"Maximum number of results")
->type_name("<number>")