feat: added --verbose to list view
This commit is contained in:
parent
b82a63eeb7
commit
a5cef7f269
1 changed files with 27 additions and 22 deletions
49
src/main.rs
49
src/main.rs
|
@ -26,7 +26,7 @@ struct PostWomanArgs {
|
||||||
multi_threaded: bool,
|
multi_threaded: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand, Debug, Default)]
|
#[derive(Subcommand, Debug)]
|
||||||
pub enum PostWomanActions {
|
pub enum PostWomanActions {
|
||||||
/// execute specific endpoint requests
|
/// execute specific endpoint requests
|
||||||
Run {
|
Run {
|
||||||
|
@ -47,21 +47,11 @@ pub enum PostWomanActions {
|
||||||
},
|
},
|
||||||
|
|
||||||
/// show all registered routes in current collection
|
/// show all registered routes in current collection
|
||||||
#[default]
|
List {
|
||||||
List,
|
/// show verbose details for each route
|
||||||
|
#[arg(short = 'V', long, default_value_t = false)]
|
||||||
// Save {
|
verbose: bool,
|
||||||
// /// name for new endpoint
|
},
|
||||||
// name: String,
|
|
||||||
// /// url of endpoint
|
|
||||||
// url: String,
|
|
||||||
// /// method
|
|
||||||
// method: Option<String>,
|
|
||||||
// /// headers
|
|
||||||
// headers: Vec<String>,
|
|
||||||
// /// body
|
|
||||||
// body: Option<String>,
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const TIMESTAMP_FMT: &str = "%H:%M:%S%.6f";
|
const TIMESTAMP_FMT: &str = "%H:%M:%S%.6f";
|
||||||
|
@ -90,19 +80,34 @@ fn main() -> Result<(), PostWomanError> {
|
||||||
async fn run_postwoman(args: PostWomanArgs, collection: PostWomanCollection) -> Result<(), PostWomanError> {
|
async fn run_postwoman(args: PostWomanArgs, collection: PostWomanCollection) -> Result<(), PostWomanError> {
|
||||||
let action = args.action.unwrap_or(PostWomanActions::List { verbose: false });
|
let action = args.action.unwrap_or(PostWomanActions::List { verbose: false });
|
||||||
|
|
||||||
match args.action.unwrap_or_default() {
|
match action {
|
||||||
PostWomanActions::List => {
|
PostWomanActions::List { verbose } => {
|
||||||
let ua = config.client.user_agent.unwrap_or(APP_USER_AGENT.to_string());
|
let ua = collection.client.user_agent.unwrap_or(APP_USER_AGENT.to_string());
|
||||||
println!("> {ua}");
|
println!("> {ua}");
|
||||||
|
|
||||||
for (key, value) in config.env {
|
for (key, value) in collection.env {
|
||||||
println!("+ {key}: {}", ext::stringify_toml(&value));
|
println!("+ {key}: {}", ext::stringify_toml(&value));
|
||||||
}
|
}
|
||||||
|
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
for (name, endpoint) in config.route {
|
for (name, mut endpoint) in collection.route {
|
||||||
println!("- {name}: \t{} \t{}", endpoint.method.unwrap_or("GET".into()), endpoint.url);
|
println!("- {name}: \t{} \t{}", endpoint.method.as_deref().unwrap_or("GET"), endpoint.url);
|
||||||
|
if verbose {
|
||||||
|
if let Some(ref query) = endpoint.query {
|
||||||
|
for query in query {
|
||||||
|
println!(" |? {query}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(ref headers) = endpoint.headers {
|
||||||
|
for header in headers {
|
||||||
|
println!(" |: {header}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Ok(body) = endpoint.body() {
|
||||||
|
println!(" |> {body}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
PostWomanActions::Run { query, parallel, repeat, debug } => {
|
PostWomanActions::Run { query, parallel, repeat, debug } => {
|
||||||
|
|
Loading…
Reference in a new issue