diff --git a/CHANGELOG.md b/CHANGELOG.md index 724d6ed..0ec0213 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Removed + +- ⚠️ `rw api --jq`/`-q` is removed; pipe output to an external `jq` instead + ## [0.12.0] - 2026-04-28 ### Added diff --git a/Cargo.lock b/Cargo.lock index 8cb948d..5bb4848 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -145,12 +145,6 @@ version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.13.1" @@ -459,37 +453,6 @@ dependencies = [ "syn 2.0.119", ] -[[package]] -name = "defmt" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2953bfe4f93bbd20cc71198842756f77d161884c99ebbabc41d80231ded88d1" -dependencies = [ - "bitflags 1.3.2", - "defmt-macros", -] - -[[package]] -name = "defmt-macros" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bad9c72e7ca2137e0dc3813245a0d282fd6daad32fd800af018306a9169b5fe8" -dependencies = [ - "defmt-parser", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "defmt-parser" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e" -dependencies = [ - "thiserror 2.0.19", -] - [[package]] name = "der" version = "0.7.10" @@ -549,7 +512,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" dependencies = [ - "bitflags 2.13.1", + "bitflags", "objc2", ] @@ -579,12 +542,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" -[[package]] -name = "dyn-clone" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" - [[package]] name = "ed25519" version = "2.2.3" @@ -694,12 +651,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - [[package]] name = "form_urlencoded" version = "1.2.2" @@ -844,12 +795,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hifijson" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "242402749acf71e6f32f5857598b7002c4058a4e3c3b22b4c7d51cab9aea754e" - [[package]] name = "http" version = "1.5.0" @@ -1092,106 +1037,6 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" -[[package]] -name = "jaq-core" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7561783b20275a6c9cb576e39208b0c635f34ef14357f1f05a2927a774f3adec" -dependencies = [ - "dyn-clone", - "once_cell", - "typed-arena", -] - -[[package]] -name = "jaq-json" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4ec9aaad7340e6990c6c1878ef3b46dbec624e535d7f786cc9ddcf94f773d33" -dependencies = [ - "bstr", - "bytes", - "foldhash", - "hifijson", - "indexmap", - "jaq-core", - "jaq-std", - "num-bigint", - "num-traits", - "ryu", - "self_cell", -] - -[[package]] -name = "jaq-std" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bdc5a74b0feeb5e6a1dc2dd08c34280a61e37668d10a6a3b27ad69d0fb9ce2e" -dependencies = [ - "aho-corasick", - "base64", - "bstr", - "jaq-core", - "jiff", - "libm", - "log", - "regex-bites", - "urlencoding", -] - -[[package]] -name = "jiff" -version = "0.2.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "668b7183bd07af9a4885f5c35b0cc5c83c4607a913c16b7e17291832910d2dcc" -dependencies = [ - "defmt", - "jiff-core", - "jiff-static", - "jiff-tzdb-platform", - "log", - "portable-atomic", - "portable-atomic-util", - "serde_core", - "windows-link", -] - -[[package]] -name = "jiff-core" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7feca88439efe53da3754500c1851dedf3cb36c524dd5cf8225cc0794de95d09" -dependencies = [ - "defmt", -] - -[[package]] -name = "jiff-static" -version = "0.2.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a69dcb3a21cfb32ce1cd056169337ca284af0766dd766e7878819b251a49204" -dependencies = [ - "jiff-core", - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "jiff-tzdb" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "142bd39932ad231f10513df9ab62661fead8719872150b7ad02a2df79f4e141e" - -[[package]] -name = "jiff-tzdb-platform" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "875a5a69ac2bab1a891711cf5eccbec1ce0341ea805560dcd90b7a2e925132e8" -dependencies = [ - "jiff-tzdb", -] - [[package]] name = "jni" version = "0.22.4" @@ -1280,12 +1125,6 @@ version = "0.2.189" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" -[[package]] -name = "libm" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" - [[package]] name = "libredox" version = "0.1.19" @@ -1398,31 +1237,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" -[[package]] -name = "num-bigint" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367" -dependencies = [ - "num-integer", - "num-traits", -] - [[package]] name = "num-conv" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -1447,7 +1267,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" dependencies = [ - "bitflags 2.13.1", + "bitflags", "objc2", "objc2-foundation", ] @@ -1458,7 +1278,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ - "bitflags 2.13.1", + "bitflags", "dispatch2", "objc2", ] @@ -1475,7 +1295,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" dependencies = [ - "bitflags 2.13.1", + "bitflags", "objc2", "objc2-core-foundation", ] @@ -1566,21 +1386,6 @@ version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" -[[package]] -name = "portable-atomic" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d20d5497ef88037a52ff98267d066e7f11fcc5e99bbfbd58a42336193aacec3" - -[[package]] -name = "portable-atomic-util" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2a106d1259c23fac8e543272398ae0e3c0b8d33c88ed73d0cc71b0f1d902618" -dependencies = [ - "portable-atomic", -] - [[package]] name = "potential_utf" version = "0.1.5" @@ -1836,7 +1641,7 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags 2.13.1", + "bitflags", ] [[package]] @@ -1873,12 +1678,6 @@ dependencies = [ "regex-syntax", ] -[[package]] -name = "regex-bites" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a15a2fa0bfda9361941c45550896ae87b15cc6c8c939ea350079670332e211" - [[package]] name = "regex-syntax" version = "0.8.11" @@ -1982,7 +1781,7 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags 2.13.1", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -2081,9 +1880,6 @@ dependencies = [ "base64", "clap", "dirs", - "jaq-core", - "jaq-json", - "jaq-std", "json_dotpath", "mockito", "predicates", @@ -2138,7 +1934,7 @@ version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ - "bitflags 2.13.1", + "bitflags", "core-foundation", "core-foundation-sys", "libc", @@ -2166,12 +1962,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "self_cell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab42ca02749e120097e328d91d415325bdf43b1c72c4c8badf37375fe40a813" - [[package]] name = "self_update" version = "1.0.0-rc.6" @@ -2655,7 +2445,7 @@ version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" dependencies = [ - "bitflags 2.13.1", + "bitflags", "bytes", "futures-util", "http", @@ -2704,12 +2494,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" -[[package]] -name = "typed-arena" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" - [[package]] name = "typenum" version = "1.20.1" diff --git a/Cargo.toml b/Cargo.toml index ff0a3a2..ac4b562 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,9 +19,6 @@ base64 = "0.22" dirs = "6" write_atomic = "0.7" webbrowser = "1" -jaq-core = "3.0.0" -jaq-std = "3.0.0" -jaq-json = "2.0.0" uuid = { version = "1", features = ["v4"] } rpassword = "7" json_dotpath = "1" diff --git a/README.md b/README.md index fd264dd..5d8d4c2 100644 --- a/README.md +++ b/README.md @@ -286,9 +286,6 @@ rw api clinicians --method POST --field data.attributes.name="Alice Avalon" --fi # Add extra request headers rw api clinicians --header "Accept: application/json" -# Filter output with a jq expression -rw api clinicians --jq '.[0]' - # Print raw (unpretty) JSON rw api clinicians --raw @@ -296,9 +293,6 @@ rw api clinicians --raw rw api clinicians --profile demo ``` -_**Note**: jq expression filtering uses [jaq](https://github.com/01mf02/jaq), which may have slight differences -in formatting and may not support all jq features._ - Stage-to-base-URL mapping (the endpoint you pass is appended to this): | Stage | Base URL | diff --git a/src/cli.rs b/src/cli.rs index b8455d0..ff1af0f 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -474,10 +474,6 @@ pub struct ApiArgs { #[arg(short = 'f', long = "field")] pub fields: Vec, - /// Filter output with a jq expression. - #[arg(short = 'q', long)] - pub jq: Option, - /// Output raw JSON without pretty-printing. #[arg(long)] pub raw: bool, diff --git a/src/commands/api.rs b/src/commands/api.rs index 4f2f701..c34b43b 100644 --- a/src/commands/api.rs +++ b/src/commands/api.rs @@ -1,7 +1,4 @@ use anyhow::{bail, Context, Result}; -use jaq_core::load::{Arena, File, Loader}; -use jaq_core::{data, unwrap_valr, Compiler, Ctx, Vars}; -use jaq_json::{read, Val}; use json_dotpath::DotPaths; use reqwest::header::{HeaderMap, HeaderName, HeaderValue}; @@ -16,7 +13,6 @@ pub async fn dispatch(args: ApiArgs, ctx: &AppContext, _out: &Output) -> Result< &args.method, &args.headers, &args.fields, - args.jq.as_deref(), args.raw, ) .await @@ -30,7 +26,6 @@ pub async fn dispatch(args: ApiArgs, ctx: &AppContext, _out: &Output) -> Result< /// * `method` – HTTP verb (e.g. `GET`, `POST`) /// * `extra_headers` – additional raw header strings (`"Name: value"`) /// * `fields` – request body key=value pairs; forces POST when present -/// * `jq` – optional jq filter expression to apply to the response /// * `raw` – if true, print raw JSON; otherwise pretty-print pub async fn run( ctx: &AppContext, @@ -38,7 +33,6 @@ pub async fn run( method: &str, extra_headers: &[String], fields: &[String], - jq: Option<&str>, raw: bool, ) -> Result<()> { // Strip leading slash from endpoint so we can join cleanly. @@ -90,9 +84,7 @@ pub async fn run( bail!("API returned {}: {}", status, body); } - if let Some(filter) = jq { - print!("{}", apply_jq(filter, &body)?); - } else if raw { + if raw { print!("{}", body); } else { // Pretty-print JSON when possible; fall back to raw output. @@ -105,57 +97,6 @@ pub async fn run( Ok(()) } -/// Apply a jq filter expression to `json` using the `jaq-core` library. -fn apply_jq(filter_str: &str, json: &str) -> Result { - let input = read::parse_single(json.as_bytes()) - .map_err(|e| anyhow::anyhow!("jq: invalid JSON input: {e}"))?; - - let program = File { - code: filter_str, - path: (), - }; - - let defs = jaq_core::defs() - .chain(jaq_std::defs()) - .chain(jaq_json::defs()); - let funs = jaq_core::funs() - .chain(jaq_std::funs()) - .chain(jaq_json::funs()); - - let loader = Loader::new(defs); - let arena = Arena::default(); - - let modules = loader - .load(&arena, program) - .map_err(|errs| anyhow::anyhow!("jq: {}", format_load_errors(errs)))?; - - let filter = Compiler::default() - .with_funs(funs) - .compile(modules) - .map_err(|errs| anyhow::anyhow!("jq: {errs:?}"))?; - - let ctx = Ctx::>::new(&filter.lut, Vars::new([])); - let out = filter.id.run((ctx, input)).map(unwrap_valr); - - let mut output = String::new(); - for result in out { - let val = result.map_err(|e| anyhow::anyhow!("jq: {e}"))?; - if !output.is_empty() { - output.push('\n'); - } - output.push_str(&val.to_string()); - } - if !output.is_empty() { - output.push('\n'); - } - - Ok(output) -} - -fn format_load_errors(errs: E) -> String { - format!("{errs:?}") -} - /// Parse a raw `"Name: value"` header string into typed header components. fn parse_header(s: &str) -> Result<(HeaderName, HeaderValue)> { let colon = s @@ -341,32 +282,4 @@ mod tests { fn test_parse_field_invalid() { assert!(parse_field("no-equals").is_err()); } - - #[test] - fn test_apply_jq_identity() { - let result = apply_jq(".", r#"{"a":1}"#).unwrap(); - assert_eq!(result.trim(), r#"{"a":1}"#); - } - - #[test] - fn test_apply_jq_field_access() { - let result = apply_jq(".name", r#"{"name":"Alice"}"#).unwrap(); - assert_eq!(result.trim(), r#""Alice""#); - } - - #[test] - fn test_apply_jq_array_iterator() { - let result = apply_jq(".[]", r#"[1,2,3]"#).unwrap(); - assert_eq!(result.trim(), "1\n2\n3"); - } - - #[test] - fn test_apply_jq_invalid_filter() { - assert!(apply_jq("invalid!!!", "{}").is_err()); - } - - #[test] - fn test_apply_jq_invalid_json() { - assert!(apply_jq(".", "not-json").is_err()); - } }