refactor man and completion with clap derive api

This commit is contained in:
Clément DOUIN
2023-12-05 22:38:08 +01:00
parent 7a10a7fc25
commit d2308221d7
22 changed files with 270 additions and 233 deletions
+11 -6
View File
@@ -6,19 +6,24 @@ const ARG_DISABLE_CACHE: &str = "disable-cache";
/// Represents the disable cache flag argument. This argument allows
/// the user to disable any sort of cache.
pub fn arg() -> Arg {
Arg::new(ARG_DISABLE_CACHE)
pub fn global_args() -> impl IntoIterator<Item = Arg> {
[Arg::new(ARG_DISABLE_CACHE)
.help("Disable any sort of cache")
.long_help(
"Disable any sort of cache. The action depends on
the command it applies on.",
"Disable any sort of cache.
The action depends on commands it apply on. For example, when listing
envelopes using the IMAP backend, this flag will ensure that envelopes
are fetched from the IMAP server and not from the synchronized local
Maildir.",
)
.long("disable-cache")
.alias("no-cache")
.global(true)
.action(ArgAction::SetTrue)
.action(ArgAction::SetTrue)]
}
/// Represents the disable cache flag parser.
pub fn parse_disable_cache_flag(m: &ArgMatches) -> bool {
pub fn parse_disable_cache_arg(m: &ArgMatches) -> bool {
m.get_flag(ARG_DISABLE_CACHE)
}