Compare commits
No commits in common. "f12de311254873794e5e09ce5ad4da43f2c24737" and "d7dff98c8adf8b588c7812ea58dc5435553db30c" have entirely different histories.
f12de31125
...
d7dff98c8a
3 changed files with 9 additions and 6 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -815,7 +815,7 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "postwoman"
|
name = "postwoman"
|
||||||
version = "0.4.3"
|
version = "0.4.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "postwoman"
|
name = "postwoman"
|
||||||
description = "API tester and debugger for your CLI "
|
description = "API tester and debugger for your CLI "
|
||||||
version = "0.4.3"
|
version = "0.4.2"
|
||||||
repository = "https://moonlit.technology/alemi/postwoman"
|
repository = "https://moonlit.technology/alemi/postwoman"
|
||||||
authors = [ "alemi <me@alemi.dev>" ]
|
authors = [ "alemi <me@alemi.dev>" ]
|
||||||
license = "GPL-3.0-only"
|
license = "GPL-3.0-only"
|
||||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -72,7 +72,7 @@ fn main() {
|
||||||
|
|
||||||
let mut collections = IndexMap::new();
|
let mut collections = IndexMap::new();
|
||||||
|
|
||||||
if !load_collections(&mut collections, args.collection.clone()) {
|
if !load_collections(&mut collections, args.collection.clone(), &toml::Table::default()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ async fn run_collection_endpoints(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_collections(store: &mut IndexMap<String, PostWomanCollection>, mut path: std::path::PathBuf) -> bool {
|
fn load_collections(store: &mut IndexMap<String, PostWomanCollection>, mut path: std::path::PathBuf, parent_env: &toml::Table) -> bool {
|
||||||
let collection_raw = match std::fs::read_to_string(&path) {
|
let collection_raw = match std::fs::read_to_string(&path) {
|
||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
@ -221,7 +221,7 @@ fn load_collections(store: &mut IndexMap<String, PostWomanCollection>, mut path:
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let collection: PostWomanCollection = match toml::from_str(&collection_raw) {
|
let mut collection: PostWomanCollection = match toml::from_str(&collection_raw) {
|
||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("! error parsing collection {path:?}: {e}");
|
eprintln!("! error parsing collection {path:?}: {e}");
|
||||||
|
@ -229,6 +229,8 @@ fn load_collections(store: &mut IndexMap<String, PostWomanCollection>, mut path:
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
collection.env.extend(parent_env.iter().map(|(k, v)| (k.clone(), v.clone())));
|
||||||
|
|
||||||
let name = path.to_string_lossy().replace(".toml", "");
|
let name = path.to_string_lossy().replace(".toml", "");
|
||||||
let mut to_include = Vec::new();
|
let mut to_include = Vec::new();
|
||||||
|
|
||||||
|
@ -240,10 +242,11 @@ fn load_collections(store: &mut IndexMap<String, PostWomanCollection>, mut path:
|
||||||
to_include.push(base);
|
to_include.push(base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let parent_env = collection.env.clone();
|
||||||
store.insert(name, collection);
|
store.insert(name, collection);
|
||||||
|
|
||||||
for base in to_include {
|
for base in to_include {
|
||||||
if !load_collections(store, base) {
|
if !load_collections(store, base, &parent_env) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue