Compare commits

..

No commits in common. "553a5fc68ef6ccf16578bd9288a0d346c4d52fd2" and "afc582b0a6d6a91bedaa550e173db06dfdf35a06" have entirely different histories.

5 changed files with 10 additions and 113 deletions

90
Cargo.lock generated
View file

@ -238,37 +238,6 @@ version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa"
[[package]]
name = "crossbeam-deque"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d"
dependencies = [
"crossbeam-epoch",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
[[package]]
name = "either"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
[[package]]
name = "encoding_rs"
version = "0.8.32"
@ -590,7 +559,6 @@ checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da"
dependencies = [
"equivalent",
"hashbrown",
"rayon",
"serde",
]
@ -632,29 +600,6 @@ version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
[[package]]
name = "jql-parser"
version = "7.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc6c5d45258356a8b4ff8265b929cc95880be34fdc34c884e0ab4585d4a3f356"
dependencies = [
"thiserror",
"winnow",
]
[[package]]
name = "jql-runner"
version = "7.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26d68343315f3a2668bf340993d0ae2686bed277d2fb74b28a083fc50fd1db44"
dependencies = [
"indexmap",
"jql-parser",
"rayon",
"serde_json",
"thiserror",
]
[[package]]
name = "js-sys"
version = "0.3.72"
@ -873,7 +818,6 @@ dependencies = [
"clap",
"http",
"indexmap",
"jql-runner",
"regex",
"reqwest",
"serde",
@ -902,26 +846,6 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "rayon"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa"
dependencies = [
"either",
"rayon-core",
]
[[package]]
name = "rayon-core"
version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2"
dependencies = [
"crossbeam-deque",
"crossbeam-utils",
]
[[package]]
name = "redox_syscall"
version = "0.3.5"
@ -1123,18 +1047,18 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.210"
version = "1.0.164"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a"
checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.210"
version = "1.0.164"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68"
dependencies = [
"proc-macro2",
"quote",
@ -1143,13 +1067,11 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.132"
version = "1.0.97"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03"
checksum = "bdf3bf93142acad5821c99197022e170842cdbc1c30482b98750c688c640842a"
dependencies = [
"indexmap",
"itoa",
"memchr",
"ryu",
"serde",
]

View file

@ -11,7 +11,6 @@ chrono = "0.4"
clap = { version = "4.5", features = ["derive"] }
http = "1.1.0"
indexmap = { version = "2.6", features = ["serde"] }
jql-runner = "7.2"
regex = "1.11"
reqwest = { version = "0.12", features = ["json"] }
serde = { version = "1.0", features = ["derive"] }

View file

@ -36,10 +36,4 @@ pub enum PostWomanError {
#[error("invalid regex: {0:?}")]
InvalidRegex(#[from] regex::Error),
#[error("invalid JQL query: {0:?}")]
JQLError(#[from] jql_runner::errors::JqlRunnerError),
#[error("regex failed matching in content: {0}")]
NoMatch(String),
}

View file

@ -126,14 +126,10 @@ impl Endpoint {
.error_for_status()?;
Ok(match self.extract.unwrap_or_default() {
StringOr::Str(_query) => todo!(),
StringOr::T(Extractor::Discard) => "".to_string(),
StringOr::T(Extractor::Debug) => format!("{res:#?}\nBody: ") + &format_body(res).await? + "\n", // ughhh
StringOr::T(Extractor::Body) => format_body(res).await?,
StringOr::T(Extractor::Debug) => {
// TODO needless double format
let res_dbg = format!("{res:#?}");
let body = format_body(res).await?;
format!("{res_dbg}\nBody: {body}\n")
},
StringOr::T(Extractor::Header { key }) => res
.headers()
.get(&key)
@ -141,20 +137,6 @@ impl Endpoint {
.to_str()?
.to_string()
+ "\n",
StringOr::T(Extractor::Regex { pattern }) => {
let pattern = regex::Regex::new(&pattern)?;
let body = format_body(res).await?;
pattern.find(&body)
.ok_or_else(|| PostWomanError::NoMatch(body.clone()))?
.as_str()
.to_string()
},
// bare string defaults to JQL query
StringOr::T(Extractor::Jql { query }) | StringOr::Str(query) => {
let json: serde_json::Value = res.json().await?;
let selection = jql_runner::runner::raw(&query, &json)?;
serde_json::to_string_pretty(&selection)?
},
})
}
}

View file

@ -6,7 +6,7 @@ pub enum Extractor {
Debug,
Body,
Discard,
Jql { query: String },
Regex { pattern: String },
// JQL { query: String },
// Regex { pattern: String },
Header { key: String },
}