diff --git a/src/main.rs b/src/main.rs index f750b06..4a01dd1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,7 +68,9 @@ async fn main() -> Result<(), Box> { }; println!("╶┐ * {}", collection.info.name); - println!(" │ {}", collection.info.description); + if let Some(descr) = collection.info.description { + println!(" │ {}", descr); + } println!(" │"); match args.action { @@ -78,7 +80,8 @@ async fn main() -> Result<(), Box> { let item = Item { name: "TODO!".into(), event: None, - request: Request { + item: None, + request: Some(Request { url: crate::proto::Url::String(url), method: method.to_string(), header: Some( @@ -92,8 +95,8 @@ async fn main() -> Result<(), Box> { ), body: if data.len() > 0 { Some(Body::Text(data)) } else { None }, description: None, - }, - response: vec![], + }), + response: Some(vec![]), }; if debug { diff --git a/src/model.rs b/src/model.rs index a0621cc..fa57352 100644 --- a/src/model.rs +++ b/src/model.rs @@ -6,6 +6,18 @@ use crate::proto::Item; impl Item { pub async fn send(&self) -> Result { + if let Some(items) = self.item { + let tasks = vec![]; + for i in items { + tasks.push( + tokio::spawn(async { i.send().await }) + ) + } + for t in tasks { + t.await.unwrap()?; + } + + } let method = Method::from_bytes( self.request.method.as_bytes() // TODO lol? ).unwrap_or(Method::GET); // TODO throw an error rather than replacing it silently diff --git a/src/proto.rs b/src/proto.rs index 9ba5e45..560a20f 100644 --- a/src/proto.rs +++ b/src/proto.rs @@ -10,7 +10,7 @@ pub struct PostWomanCollection { #[derive(Serialize, Deserialize, Debug)] pub struct CollectionInfo { pub name: String, - pub description: String, + pub description: Option, pub schema: String, pub _postman_id: Option, @@ -20,8 +20,9 @@ pub struct CollectionInfo { pub struct Item { pub name: String, pub event: Option>, - pub request: Request, - pub response: Vec, // TODO surely isn't just strings + pub request: Option, + pub response: Option>, // TODO surely isn't just strings + pub item: Option>, } #[derive(Serialize, Deserialize, Debug)]