Skip to content

Commit c3bb3d5

Browse files
Bartok9Bartok9
authored andcommitted
fix(cli): rustfmt + clippy for external-agent listen path
Address CI Rust Lint (fmt) and Windows clippy cloned_ref_to_slice_refs on buzz listen tests. Signed-off-by: Bartok9 <danielrpike9@gmail.com> (cherry picked from commit 2c28285) Signed-off-by: Bartok9 <259807879+Bartok9@users.noreply.github.com> (cherry picked from commit 3f2ec27) Signed-off-by: Bartok9 <259807879+Bartok9@users.noreply.github.com> (cherry picked from commit d31d609) Signed-off-by: Bartok9 <259807879+Bartok9@users.noreply.github.com>
1 parent 1d2065a commit c3bb3d5

4 files changed

Lines changed: 19 additions & 22 deletions

File tree

crates/buzz-cli/src/commands/listen.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ fn parse_kinds(raw: Option<&str>) -> Result<Vec<u32>, CliError> {
3636
out.push(k);
3737
}
3838
if out.is_empty() {
39-
return Err(CliError::Usage("--kinds must list at least one kind".into()));
39+
return Err(CliError::Usage(
40+
"--kinds must list at least one kind".into(),
41+
));
4042
}
4143
Ok(out)
4244
}
@@ -88,10 +90,7 @@ async fn post_webhook(client: &reqwest::Client, url: &str, body: &str) {
8890
.send()
8991
.await
9092
{
91-
eprintln!(
92-
"{}",
93-
json!({"error":"webhook","message": format!("{e}")})
94-
);
93+
eprintln!("{}", json!({"error":"webhook","message": format!("{e}")}));
9594
}
9695
}
9796

@@ -184,13 +183,10 @@ async fn listen_session(
184183
) -> Result<(), CliError> {
185184
use buzz_ws_client::{NostrWsConnection, RelayMessage};
186185

187-
let mut conn = NostrWsConnection::connect_authenticated(
188-
ws_url,
189-
client.keys(),
190-
client.auth_tag(),
191-
)
192-
.await
193-
.map_err(|e| CliError::Other(format!("websocket: {e}")))?;
186+
let mut conn =
187+
NostrWsConnection::connect_authenticated(ws_url, client.keys(), client.auth_tag())
188+
.await
189+
.map_err(|e| CliError::Other(format!("websocket: {e}")))?;
194190

195191
let sub_id = format!("buzz-listen-{}", &Uuid::new_v4().to_string()[..8]);
196192
let mut req = vec![json!("REQ"), json!(sub_id)];
@@ -215,8 +211,7 @@ async fn listen_session(
215211
.map_err(|e| CliError::Other(format!("event serialize: {e}")))?;
216212
let line = normalize_events(std::slice::from_ref(&raw));
217213
// normalize_events returns a JSON array; unwrap first element for NDJSON stream.
218-
let arr: Vec<serde_json::Value> =
219-
serde_json::from_str(&line).unwrap_or_default();
214+
let arr: Vec<serde_json::Value> = serde_json::from_str(&line).unwrap_or_default();
220215
let body = arr.first().cloned().unwrap_or(raw);
221216
let text = serde_json::to_string(&body).unwrap_or_default();
222217
println!("{text}");
@@ -256,7 +251,13 @@ mod tests {
256251
#[test]
257252
fn channel_filter_uses_h_tag() {
258253
let ch = "11111111-1111-1111-1111-111111111111".to_string();
259-
let f = build_listen_filters(&[ch.clone()], false, &"a".repeat(64), DEFAULT_KINDS).unwrap();
254+
let f = build_listen_filters(
255+
std::slice::from_ref(&ch),
256+
false,
257+
&"a".repeat(64),
258+
DEFAULT_KINDS,
259+
)
260+
.unwrap();
260261
assert_eq!(f.len(), 1);
261262
assert_eq!(f[0]["#h"][0], ch);
262263
}

crates/buzz-cli/src/commands/messages.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,6 @@ mod tests {
15761576
}
15771577
}
15781578

1579-
15801579
#[cfg(test)]
15811580
mod compact_format_tests {
15821581
use super::format_events;

crates/buzz-cli/src/commands/users.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ pub(crate) fn me_identity_json(pubkey_hex: &str, npub_bech32: &str) -> serde_jso
1919
/// Print the active CLI identity (hex pubkey + npub) from the loaded private key.
2020
///
2121
/// No relay I/O — agents can resolve "who am I?" before connecting. Refs #2663.
22-
pub async fn cmd_me(
23-
client: &BuzzClient,
24-
_format: &crate::OutputFormat,
25-
) -> Result<(), CliError> {
22+
pub async fn cmd_me(client: &BuzzClient, _format: &crate::OutputFormat) -> Result<(), CliError> {
2623
let pk = client.keys().public_key();
2724
let hex = pk.to_hex();
2825
let npub = pk

crates/buzz-cli/src/managed_agent_publish.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ pub fn build_managed_agent_event(
151151
.map_err(|e| CliError::Usage(format!("invalid agent pubkey: {e}")))?;
152152
let body = serde_json::to_string(content)
153153
.map_err(|e| CliError::Other(format!("serialize 30177: {e}")))?;
154-
let d = Tag::parse(["d", agent_pubkey_hex])
155-
.map_err(|e| CliError::Other(format!("d-tag: {e}")))?;
154+
let d =
155+
Tag::parse(["d", agent_pubkey_hex]).map_err(|e| CliError::Other(format!("d-tag: {e}")))?;
156156
Ok(EventBuilder::new(Kind::Custom(KIND_MANAGED_AGENT as u16), body).tags([d]))
157157
}
158158

0 commit comments

Comments
 (0)