Compare commits
No commits in common. "748e81af4b9c6e01a025e9c0c6a39f2fd24a6e6e" and "f12de311254873794e5e09ce5ad4da43f2c24737" have entirely different histories.
748e81af4b
...
f12de31125
5 changed files with 14 additions and 39 deletions
9
Cargo.lock
generated
9
Cargo.lock
generated
|
@ -260,12 +260,6 @@ version = "0.8.7"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
|
||||
|
||||
[[package]]
|
||||
name = "dotenv"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
|
||||
|
||||
[[package]]
|
||||
name = "dyn-clone"
|
||||
version = "1.0.17"
|
||||
|
@ -821,12 +815,11 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
|
|||
|
||||
[[package]]
|
||||
name = "postwoman"
|
||||
version = "0.4.4"
|
||||
version = "0.4.3"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"chrono",
|
||||
"clap",
|
||||
"dotenv",
|
||||
"http",
|
||||
"indexmap",
|
||||
"jaq-interpret",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "postwoman"
|
||||
description = "API tester and debugger for your CLI "
|
||||
version = "0.4.4"
|
||||
version = "0.4.3"
|
||||
repository = "https://moonlit.technology/alemi/postwoman"
|
||||
authors = [ "alemi <me@alemi.dev>" ]
|
||||
license = "GPL-3.0-only"
|
||||
|
@ -13,7 +13,6 @@ edition = "2021"
|
|||
base64 = "0.22.1"
|
||||
chrono = "0.4"
|
||||
clap = { version = "4.5", features = ["derive"] }
|
||||
dotenv = "0.15"
|
||||
http = "1.1.0"
|
||||
indexmap = { version = "2.6", features = ["serde"] }
|
||||
jaq-interpret = "1.5"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include = ["other.toml", "api/auth.toml"] # include other postwoman collections relative to this one
|
||||
include = ["other.toml", "api/auth.toml"] # include other postwoman collections relative to this one
|
||||
|
||||
[env] # these will be replaced in fields and inherited by includes. environment vars overrule these
|
||||
PW_TOKEN = "set-me-as-and-environment-variable!"
|
||||
|
|
28
src/fmt.rs
28
src/fmt.rs
|
@ -1,6 +1,6 @@
|
|||
use indexmap::IndexMap;
|
||||
|
||||
use crate::{ext::StringOr, model::ExtractorConfig, PostWomanCollection, PostWomanError};
|
||||
use crate::{PostWomanCollection, PostWomanError};
|
||||
|
||||
pub const TIMESTAMP_FMT: &str = "%H:%M:%S%.6f";
|
||||
|
||||
|
@ -57,10 +57,10 @@ impl PrintableResult for ListResult {
|
|||
fn print(self) {
|
||||
let (collections, compact) = self;
|
||||
for (namespace, collection) in collections {
|
||||
println!("+#> {namespace}");
|
||||
println!("-> {namespace}");
|
||||
|
||||
for (key, value) in collection.env {
|
||||
println!("| {key}={}", crate::ext::stringify_toml(&value));
|
||||
println!(" + {key}={}", crate::ext::stringify_toml(&value));
|
||||
}
|
||||
|
||||
for (name, endpoint) in collection.route {
|
||||
|
@ -70,31 +70,23 @@ impl PrintableResult for ListResult {
|
|||
.unwrap_or_default()
|
||||
.to_string();
|
||||
let method = endpoint.method.as_deref().unwrap_or("GET");
|
||||
if !compact { println!("|") };
|
||||
println!("|- {name: <30} {method: <10} {url}");
|
||||
println!(" - {name} \t{method} \t{url}");
|
||||
if ! compact {
|
||||
if let Some(ref query) = endpoint.query {
|
||||
for (i, query) in query.iter().enumerate() {
|
||||
println!("| {}| {query}", if i == 0 { "Q" } else { " " });
|
||||
for query in query {
|
||||
println!(" |? {query}");
|
||||
}
|
||||
}
|
||||
if let Some(ref headers) = endpoint.headers {
|
||||
for (i, header) in headers.iter().enumerate() {
|
||||
println!("| {}| {header}", if i == 0 { "H" } else { " " });
|
||||
for header in headers {
|
||||
println!(" |: {header}");
|
||||
}
|
||||
}
|
||||
if let Some(ref _x) = endpoint.body {
|
||||
if let Ok(body) = endpoint.body() {
|
||||
println!("| B| {}", body.replace("\n", "\n| | "));
|
||||
println!(" |> {}", body.replace("\n", "\n |> "));
|
||||
} else {
|
||||
println!("| B| [!] invalid body");
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ref extract) = endpoint.extract {
|
||||
match extract {
|
||||
StringOr::Str(q) => println!("| E| {:?}", ExtractorConfig::JQ { query: q.to_string() }),
|
||||
StringOr::T(ext) => println!("| E| {ext:?}"),
|
||||
println!(" |> [!] invalid body");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -23,10 +23,6 @@ struct PostWomanArgs {
|
|||
#[arg(short, long, default_value = "postwoman.toml")]
|
||||
collection: std::path::PathBuf,
|
||||
|
||||
/// environment (.env) to load
|
||||
#[arg(short, long, default_value = ".env")]
|
||||
env: std::path::PathBuf,
|
||||
|
||||
/// action to run
|
||||
#[clap(subcommand)]
|
||||
action: Option<PostWomanActions>,
|
||||
|
@ -90,12 +86,6 @@ fn main() {
|
|||
},
|
||||
|
||||
PostWomanActions::Run { query, parallel, debug, dry_run } => {
|
||||
eprintln!("~@ {APP_USER_AGENT}");
|
||||
|
||||
if dotenv::from_path(&args.env).is_ok() {
|
||||
eprintln!(" # loaded env file {:?}", args.env);
|
||||
}
|
||||
|
||||
// note that if you remove this test, there's another .expect() below you need to manage too!
|
||||
let filter = match regex::Regex::new(query) {
|
||||
Ok(regex) => regex,
|
||||
|
@ -124,6 +114,7 @@ fn main() {
|
|||
}
|
||||
};
|
||||
|
||||
eprintln!("~@ {APP_USER_AGENT}");
|
||||
if multi_thread {
|
||||
tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
|
|
Loading…
Reference in a new issue