use clap::{Subcommand, ValueEnum};
use map_core::folders::Folder;
use pbap_core::phonebook::PhonebookPath;
#[derive(Subcommand, Debug)]
pub(crate) enum BrokerCmd {
Status,
}
#[derive(Subcommand, Debug)]
pub(crate) enum DaemonCmd {
Start {
#[arg(long)]
foreground: bool,
},
Stop,
Status,
Install {
#[arg(long)]
system: bool,
},
Uninstall {
#[arg(long)]
system: bool,
},
}
#[derive(Subcommand, Debug)]
pub(crate) enum ConfigCmd {
Show,
SetDevice {
address: String,
},
Setup,
}
#[derive(Subcommand, Debug)]
pub(crate) enum SpokeCmd {
Add {
key: String,
},
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, ValueEnum)]
pub(crate) enum FolderArg {
Inbox,
Sent,
Outbox,
Deleted,
}
pub(crate) const fn folder_arg_to_folder(arg: FolderArg) -> Folder {
match arg {
FolderArg::Inbox => Folder::Inbox,
FolderArg::Sent => Folder::Sent,
FolderArg::Outbox => Folder::Outbox,
FolderArg::Deleted => Folder::Deleted,
}
}
pub(crate) const fn folder_of(arg: Option<FolderArg>) -> Folder {
match arg {
Some(f) => folder_arg_to_folder(f),
None => Folder::Inbox,
}
}
pub(crate) const fn path_of(arg: PathArg) -> PhonebookPath {
match arg {
PathArg::Pb => PhonebookPath::Pb,
PathArg::Ich => PhonebookPath::Ich,
PathArg::Och => PhonebookPath::Och,
PathArg::Mch => PhonebookPath::Mch,
PathArg::Cch => PhonebookPath::Cch,
PathArg::Spd => PhonebookPath::Spd,
PathArg::Fav => PhonebookPath::Fav,
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, ValueEnum)]
pub(crate) enum PathArg {
Pb,
Ich,
Och,
Mch,
Cch,
Spd,
Fav,
}
pub(crate) const fn path_name(arg: PathArg) -> &'static str {
match arg {
PathArg::Pb => "pb",
PathArg::Ich => "ich",
PathArg::Och => "och",
PathArg::Mch => "mch",
PathArg::Cch => "cch",
PathArg::Spd => "spd",
PathArg::Fav => "fav",
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn path_name_matches_broker_wire_names() {
assert_eq!(path_name(PathArg::Pb), "pb");
assert_eq!(path_name(PathArg::Ich), "ich");
assert_eq!(path_name(PathArg::Och), "och");
assert_eq!(path_name(PathArg::Mch), "mch");
assert_eq!(path_name(PathArg::Cch), "cch");
assert_eq!(path_name(PathArg::Spd), "spd");
assert_eq!(path_name(PathArg::Fav), "fav");
}
}