From e44a69e93bc6b56ad924374f57dc9f3be74ea5f1 Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 21 Oct 2024 16:11:39 +0200 Subject: [PATCH] feat: allow collections without routes --- src/fmt.rs | 2 +- src/main.rs | 2 +- src/model/mod.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fmt.rs b/src/fmt.rs index 350f170..eee657c 100644 --- a/src/fmt.rs +++ b/src/fmt.rs @@ -63,7 +63,7 @@ impl PrintableResult for ListResult { println!(" + {key}={}", crate::ext::stringify_toml(&value)); } - for (name, endpoint) in collection.route { + for (name, endpoint) in collection.route.unwrap_or_default() { let url = endpoint.url(collection.client.as_ref().and_then(|x| x.base.as_deref())) .split('?') .next() diff --git a/src/main.rs b/src/main.rs index 02f4840..ef45bbe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -150,7 +150,7 @@ async fn run_collection_endpoints( let client = std::sync::Arc::new(collection.client.unwrap_or_default()); let env = std::sync::Arc::new(collection.env.unwrap_or_default()); - for (name, mut endpoint) in collection.route { + for (name, mut endpoint) in collection.route.unwrap_or_default() { if pattern.find(&name).is_none() { continue }; if debug { endpoint.extract = Some(ext::StringOr::T(model::ExtractorConfig::Debug)) }; diff --git a/src/model/mod.rs b/src/model/mod.rs index 2a7f263..3a0d403 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -12,5 +12,5 @@ pub struct PostWomanCollection { pub env: Option, pub include: Option>, // it's weird to name it singular but makes more sense in config - pub route: indexmap::IndexMap, + pub route: Option>, }