feat(labels): add show option to display labels

- add option to show labels when creating a new label
- only display labels if show is true
This commit is contained in:
Jeremiah Russell
2025-10-03 17:36:35 +01:00
committed by Jeremiah Russell
parent 8518242302
commit bdf6f56f50

View File

@@ -34,7 +34,7 @@ impl std::fmt::Debug for Labels {
impl Labels { impl Labels {
/// Create a new List struct and add the Gmail api connection. /// Create a new List struct and add the Gmail api connection.
pub async fn new(credential: &str) -> Result<Self, Error> { pub async fn new(credential: &str, show: bool) -> Result<Self, Error> {
let (config_dir, secret) = { let (config_dir, secret) = {
let config_dir = crate::utils::assure_config_dir_exists("~/.cull-gmail")?; let config_dir = crate::utils::assure_config_dir_exists("~/.cull-gmail")?;
@@ -67,6 +67,7 @@ impl Labels {
let call = hub.users().labels_list("me"); let call = hub.users().labels_list("me");
let (_response, list) = call.doit().await.map_err(Box::new)?; let (_response, list) = call.doit().await.map_err(Box::new)?;
if show {
if let Some(labels) = &list.labels { if let Some(labels) = &list.labels {
for label in labels { for label in labels {
if let Some(name) = &label.name { if let Some(name) = &label.name {
@@ -76,6 +77,7 @@ impl Labels {
} }
} }
} }
}
let (label_list, label_map) = if let Some(labels) = list.labels { let (label_list, label_map) = if let Some(labels) = list.labels {
let mut label_map = HashMap::new(); let mut label_map = HashMap::new();