feat: add list action (as default)
This commit is contained in:
parent
58900630e1
commit
68a73284c7
1 changed files with 22 additions and 3 deletions
25
src/main.rs
25
src/main.rs
|
@ -1,5 +1,6 @@
|
||||||
mod model;
|
mod model;
|
||||||
mod errors;
|
mod errors;
|
||||||
|
mod ext;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
@ -19,10 +20,10 @@ struct PostWomanArgs {
|
||||||
|
|
||||||
/// action to run
|
/// action to run
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
action: PostWomanActions,
|
action: Option<PostWomanActions>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand, Debug)]
|
#[derive(Subcommand, Debug, Default)]
|
||||||
pub enum PostWomanActions {
|
pub enum PostWomanActions {
|
||||||
/// execute specific endpoint requests
|
/// execute specific endpoint requests
|
||||||
Run {
|
Run {
|
||||||
|
@ -38,6 +39,10 @@ pub enum PostWomanActions {
|
||||||
repeat: u32,
|
repeat: u32,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// show all registered routes in current collection
|
||||||
|
#[default]
|
||||||
|
List,
|
||||||
|
|
||||||
// Save {
|
// Save {
|
||||||
// /// name for new endpoint
|
// /// name for new endpoint
|
||||||
// name: String,
|
// name: String,
|
||||||
|
@ -69,7 +74,21 @@ async fn main() -> Result<(), PostWomanError> {
|
||||||
let collection = std::fs::read_to_string(args.collection)?;
|
let collection = std::fs::read_to_string(args.collection)?;
|
||||||
let config: PostWomanConfig = toml::from_str(&collection)?;
|
let config: PostWomanConfig = toml::from_str(&collection)?;
|
||||||
|
|
||||||
match args.action {
|
match args.action.unwrap_or_default() {
|
||||||
|
PostWomanActions::List => {
|
||||||
|
let ua = config.client.user_agent.unwrap_or(APP_USER_AGENT.to_string());
|
||||||
|
println!("> {ua}");
|
||||||
|
|
||||||
|
for (key, value) in config.env {
|
||||||
|
println!("+ {key}: {}", ext::stringify_toml(&value));
|
||||||
|
}
|
||||||
|
|
||||||
|
println!();
|
||||||
|
|
||||||
|
for (name, endpoint) in config.route {
|
||||||
|
println!("- {name}: \t{} \t{}", endpoint.method.unwrap_or("GET".into()), endpoint.url);
|
||||||
|
}
|
||||||
|
},
|
||||||
PostWomanActions::Run { query, parallel, repeat } => {
|
PostWomanActions::Run { query, parallel, repeat } => {
|
||||||
let pattern = regex::Regex::new(&query)?;
|
let pattern = regex::Regex::new(&query)?;
|
||||||
let mut joinset = tokio::task::JoinSet::new();
|
let mut joinset = tokio::task::JoinSet::new();
|
||||||
|
|
Loading…
Reference in a new issue