chore: remove sample cmd

there's a default config and it outputs ugly inner tables anyway
This commit is contained in:
əlemi 2024-10-19 04:14:11 +02:00
parent f6577e6f63
commit 763fa7fbcb
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -1,9 +1,7 @@
mod model;
use std::collections::HashMap;
use clap::{Parser, Subcommand};
use model::{Endpoint, Extractor, PostWomanClient, PostWomanConfig, PostWomanError, StringOr};
use model::{PostWomanConfig, PostWomanError};
static APP_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));
@ -22,9 +20,6 @@ struct PostWomanArgs {
#[derive(Subcommand, Debug)]
pub enum PostWomanActions {
/// print an example configragion, pipe to file and start editing
Sample,
/// execute specific endpoint requests
Run {
/// regex query filter, run all with '.*'
@ -49,45 +44,6 @@ pub enum PostWomanActions {
async fn main() -> Result<(), PostWomanError> {
let args = PostWomanArgs::parse();
if matches!(args.action, PostWomanActions::Sample) {
let a = Endpoint {
url: "https://api.alemi.dev/debug".into(),
query: None,
method: None,
headers: None,
body: None,
extract: None,
};
let b = Endpoint {
url: "https://api.alemi.dev/debug".into(),
query: None,
method: Some("PUT".into()),
headers: Some(vec![
"Authorization: Bearer asdfg".into(),
"Cache: skip".into(),
]),
body: Some(StringOr::T(toml::Table::from_iter([("hello".into(), toml::Value::String("world".into()))]))),
extract: Some(StringOr::T(Extractor::Body)),
};
let client = PostWomanClient {
user_agent: Some(APP_USER_AGENT.into()),
};
let cfg = PostWomanConfig {
client,
route: HashMap::from_iter([
("simple".to_string(), a),
("json".to_string(), b),
]),
};
println!("{}", toml_edit::ser::to_string_pretty(&cfg)?);
return Ok(());
}
let collection = std::fs::read_to_string(args.collection)?;
let config: PostWomanConfig = toml::from_str(&collection)?;
@ -109,8 +65,6 @@ async fn main() -> Result<(), PostWomanError> {
// PostWomanActions::Save { name, url, method, headers, body } => {
// todo!();
// },
PostWomanActions::Sample => unreachable!(),
}
Ok(())