Skip to content

Commit e548ea9

Browse files
committed
fix: resolve formatting and clippy warnings
- Applied cargo fmt to fix formatting issues - Simplified redundant closures per clippy recommendations - Changed map_err(|e| RedisCtlError::from(e)) to map_err(RedisCtlError::from)
1 parent 794ad45 commit e548ea9

28 files changed

+138
-149
lines changed

crates/redisctl/src/commands/enterprise/actions.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ impl ActionCommands {
8282
.await
8383
.context("Failed to list actions (v2)")?
8484
} else {
85-
handler.list().await
86-
.map_err(|e| RedisCtlError::from(e))?
85+
handler.list().await.map_err(RedisCtlError::from)?
8786
};
8887

8988
// Convert to JSON Value for filtering and output

crates/redisctl/src/commands/enterprise/alerts.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ async fn handle_cluster_alerts(
284284
let response = client
285285
.get::<Value>(&endpoint)
286286
.await
287-
.map_err(|e| RedisCtlError::from(e))?;
287+
.map_err(RedisCtlError::from)?;
288288

289289
let response = if let Some(q) = query {
290290
super::utils::apply_jmespath(&response, q)?
@@ -315,7 +315,7 @@ async fn handle_node_alerts(
315315
let response = client
316316
.get::<Value>(&endpoint)
317317
.await
318-
.map_err(|e| RedisCtlError::from(e))?;
318+
.map_err(RedisCtlError::from)?;
319319

320320
let response = if let Some(q) = query {
321321
super::utils::apply_jmespath(&response, q)?
@@ -346,7 +346,7 @@ async fn handle_database_alerts(
346346
let response = client
347347
.get::<Value>(&endpoint)
348348
.await
349-
.map_err(|e| RedisCtlError::from(e))?;
349+
.map_err(RedisCtlError::from)?;
350350

351351
let response = if let Some(q) = query {
352352
super::utils::apply_jmespath(&response, q)?
@@ -369,7 +369,7 @@ async fn handle_get_alert_settings(
369369
let response = client
370370
.get::<Value>("/v1/cluster")
371371
.await
372-
.map_err(|e| RedisCtlError::from(e))?;
372+
.map_err(RedisCtlError::from)?;
373373

374374
// Extract alert_settings from the cluster config
375375
let alert_settings = response
@@ -405,7 +405,7 @@ async fn handle_update_alert_settings(
405405
let response = client
406406
.put::<_, Value>("/v1/cluster", &update_payload)
407407
.await
408-
.map_err(|e| RedisCtlError::from(e))?;
408+
.map_err(RedisCtlError::from)?;
409409

410410
let response = if let Some(q) = query {
411411
super::utils::apply_jmespath(&response, q)?

crates/redisctl/src/commands/enterprise/bdb_group.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl BdbGroupCommands {
8282
let response: serde_json::Value = client
8383
.get("/v1/bdb_groups")
8484
.await
85-
.map_err(|e| RedisCtlError::from(e))?;
85+
.map_err(RedisCtlError::from)?;
8686

8787
let output_data = if let Some(q) = query {
8888
super::utils::apply_jmespath(&response, q)?
@@ -96,7 +96,7 @@ impl BdbGroupCommands {
9696
let response: serde_json::Value = client
9797
.get(&format!("/v1/bdb_groups/{}", uid))
9898
.await
99-
.map_err(|e| RedisCtlError::from(e))?;
99+
.map_err(RedisCtlError::from)?;
100100

101101
let output_data = if let Some(q) = query {
102102
super::utils::apply_jmespath(&response, q)?
@@ -112,7 +112,7 @@ impl BdbGroupCommands {
112112
let response: serde_json::Value = client
113113
.post("/v1/bdb_groups", &json_data)
114114
.await
115-
.map_err(|e| RedisCtlError::from(e))?;
115+
.map_err(RedisCtlError::from)?;
116116

117117
let output_data = if let Some(q) = query {
118118
super::utils::apply_jmespath(&response, q)?
@@ -128,7 +128,7 @@ impl BdbGroupCommands {
128128
let response: serde_json::Value = client
129129
.put(&format!("/v1/bdb_groups/{}", uid), &json_data)
130130
.await
131-
.map_err(|e| RedisCtlError::from(e))?;
131+
.map_err(RedisCtlError::from)?;
132132

133133
let output_data = if let Some(q) = query {
134134
super::utils::apply_jmespath(&response, q)?
@@ -148,7 +148,7 @@ impl BdbGroupCommands {
148148
client
149149
.delete(&format!("/v1/bdb_groups/{}", uid))
150150
.await
151-
.map_err(|e| RedisCtlError::from(e))?;
151+
.map_err(RedisCtlError::from)?;
152152

153153
println!("Database group {} deleted successfully", uid);
154154
}
@@ -161,7 +161,7 @@ impl BdbGroupCommands {
161161
let mut group_data: serde_json::Value = client
162162
.get(&format!("/v1/bdb_groups/{}", group_uid))
163163
.await
164-
.map_err(|e| RedisCtlError::from(e))?;
164+
.map_err(RedisCtlError::from)?;
165165

166166
// Add database to the group
167167
if let Some(bdbs) = group_data["bdbs"].as_array_mut() {
@@ -179,7 +179,7 @@ impl BdbGroupCommands {
179179
let response: serde_json::Value = client
180180
.put(&format!("/v1/bdb_groups/{}", group_uid), &group_data)
181181
.await
182-
.map_err(|e| RedisCtlError::from(e))?;
182+
.map_err(RedisCtlError::from)?;
183183

184184
println!("Database {} added to group {}", database, group_uid);
185185

@@ -199,7 +199,7 @@ impl BdbGroupCommands {
199199
let mut group_data: serde_json::Value = client
200200
.get(&format!("/v1/bdb_groups/{}", group_uid))
201201
.await
202-
.map_err(|e| RedisCtlError::from(e))?;
202+
.map_err(RedisCtlError::from)?;
203203

204204
// Remove database from the group
205205
if let Some(bdbs) = group_data["bdbs"].as_array_mut() {
@@ -218,7 +218,7 @@ impl BdbGroupCommands {
218218
let response: serde_json::Value = client
219219
.put(&format!("/v1/bdb_groups/{}", group_uid), &group_data)
220220
.await
221-
.map_err(|e| RedisCtlError::from(e))?;
221+
.map_err(RedisCtlError::from)?;
222222

223223
println!("Database {} removed from group {}", database, group_uid);
224224

@@ -234,7 +234,7 @@ impl BdbGroupCommands {
234234
let response: serde_json::Value = client
235235
.get(&format!("/v1/bdb_groups/{}", group_uid))
236236
.await
237-
.map_err(|e| RedisCtlError::from(e))?;
237+
.map_err(RedisCtlError::from)?;
238238

239239
// Extract just the databases list
240240
let databases = &response["bdbs"];

crates/redisctl/src/commands/enterprise/bootstrap.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async fn handle_bootstrap_status(
7575
let response = client
7676
.get::<Value>("/v1/bootstrap")
7777
.await
78-
.map_err(|e| RedisCtlError::from(e))?;
78+
.map_err(RedisCtlError::from)?;
7979

8080
let result = if let Some(q) = query {
8181
utils::apply_jmespath(&response, q)?
@@ -102,7 +102,7 @@ async fn handle_create_cluster(
102102
let response = client
103103
.post_raw("/v1/bootstrap/create_cluster", payload)
104104
.await
105-
.map_err(|e| RedisCtlError::from(e))?;
105+
.map_err(RedisCtlError::from)?;
106106

107107
let result = if let Some(q) = query {
108108
utils::apply_jmespath(&response, q)?
@@ -129,7 +129,7 @@ async fn handle_join_cluster(
129129
let response = client
130130
.post_raw("/v1/bootstrap/join_cluster", payload)
131131
.await
132-
.map_err(|e| RedisCtlError::from(e))?;
132+
.map_err(RedisCtlError::from)?;
133133

134134
let result = if let Some(q) = query {
135135
utils::apply_jmespath(&response, q)?

crates/redisctl/src/commands/enterprise/cluster_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ pub async fn bootstrap_cluster(
165165
let result = client
166166
.post_raw("/v1/bootstrap", bootstrap_data)
167167
.await
168-
.map_err(|e| RedisCtlError::from(e))?;
168+
.map_err(RedisCtlError::from)?;
169169
let data = handle_output(result, output_format, query)?;
170170
print_formatted_output(data, output_format)?;
171171
Ok(())

crates/redisctl/src/commands/enterprise/cm_settings.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl CmSettingsCommands {
101101
let response: serde_json::Value = client
102102
.get("/v1/cm_settings")
103103
.await
104-
.map_err(|e| RedisCtlError::from(e))?;
104+
.map_err(RedisCtlError::from)?;
105105

106106
let output_data = if let Some(s) = setting {
107107
// Use the setting parameter as a JMESPath query
@@ -121,11 +121,10 @@ impl CmSettingsCommands {
121121

122122
let json_data = super::utils::read_json_data(data)?;
123123

124-
let response: serde_json::Value =
125-
client
126-
.put("/v1/cm_settings", &json_data)
127-
.await
128-
.map_err(|e| RedisCtlError::from(e))?;
124+
let response: serde_json::Value = client
125+
.put("/v1/cm_settings", &json_data)
126+
.await
127+
.map_err(RedisCtlError::from)?;
129128

130129
println!("Cluster manager settings updated successfully");
131130

@@ -147,7 +146,7 @@ impl CmSettingsCommands {
147146
let mut settings: serde_json::Value = client
148147
.get("/v1/cm_settings")
149148
.await
150-
.map_err(|e| RedisCtlError::from(e))?;
149+
.map_err(RedisCtlError::from)?;
151150

152151
// Parse value as JSON if possible, otherwise as string
153152
let parsed_value: serde_json::Value =
@@ -174,7 +173,7 @@ impl CmSettingsCommands {
174173
let response: serde_json::Value = client
175174
.put("/v1/cm_settings", &settings)
176175
.await
177-
.map_err(|e| RedisCtlError::from(e))?;
176+
.map_err(RedisCtlError::from)?;
178177

179178
println!("Setting '{}' updated to: {}", name, value);
180179

@@ -199,7 +198,7 @@ impl CmSettingsCommands {
199198
let response: serde_json::Value = client
200199
.put("/v1/cm_settings", &serde_json::json!({}))
201200
.await
202-
.map_err(|e| RedisCtlError::from(e))?;
201+
.map_err(RedisCtlError::from)?;
203202

204203
println!("Cluster manager settings reset to defaults");
205204

@@ -215,7 +214,7 @@ impl CmSettingsCommands {
215214
let settings: serde_json::Value = client
216215
.get("/v1/cm_settings")
217216
.await
218-
.map_err(|e| RedisCtlError::from(e))?;
217+
.map_err(RedisCtlError::from)?;
219218

220219
if output == "-" {
221220
// Output to stdout
@@ -241,7 +240,7 @@ impl CmSettingsCommands {
241240
let response: serde_json::Value = client
242241
.put("/v1/cm_settings", &json_data)
243242
.await
244-
.map_err(|e| RedisCtlError::from(e))?;
243+
.map_err(RedisCtlError::from)?;
245244

246245
println!("Settings imported successfully");
247246

@@ -280,7 +279,7 @@ impl CmSettingsCommands {
280279
let settings: serde_json::Value = client
281280
.get("/v1/cm_settings")
282281
.await
283-
.map_err(|e| RedisCtlError::from(e))?;
282+
.map_err(RedisCtlError::from)?;
284283

285284
// Extract top-level keys as categories
286285
let categories = if let Some(obj) = settings.as_object() {
@@ -302,7 +301,7 @@ impl CmSettingsCommands {
302301
let settings: serde_json::Value = client
303302
.get("/v1/cm_settings")
304303
.await
305-
.map_err(|e| RedisCtlError::from(e))?;
304+
.map_err(RedisCtlError::from)?;
306305

307306
// Extract specific category
308307
let category_data = &settings[category];

crates/redisctl/src/commands/enterprise/crdb_impl.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub async fn list_crdbs(
2323
let response = client
2424
.get_raw("/v1/crdbs")
2525
.await
26-
.map_err(|e| RedisCtlError::from(e))?;
26+
.map_err(RedisCtlError::from)?;
2727

2828
let data = handle_output(response, output_format, query)?;
2929
print_formatted_output(data, output_format)?;
@@ -63,7 +63,7 @@ pub async fn create_crdb(
6363
let response = client
6464
.post_raw("/v1/crdbs", json_data)
6565
.await
66-
.map_err(|e| RedisCtlError::from(e))?;
66+
.map_err(RedisCtlError::from)?;
6767

6868
let data = handle_output(response, output_format, query)?;
6969
print_formatted_output(data, output_format)?;
@@ -582,7 +582,7 @@ pub async fn update_cluster_in_crdb(
582582
update_data,
583583
)
584584
.await
585-
.map_err(|e| RedisCtlError::from(e))?;
585+
.map_err(RedisCtlError::from)?;
586586

587587
let data = handle_output(result, output_format, query)?;
588588
print_formatted_output(data, output_format)?;
@@ -608,7 +608,7 @@ pub async fn get_conflicts(
608608
let result = client
609609
.get_raw(&url)
610610
.await
611-
.map_err(|e| RedisCtlError::from(e))?;
611+
.map_err(RedisCtlError::from)?;
612612

613613
let data = handle_output(result, output_format, query)?;
614614
print_formatted_output(data, output_format)?;
@@ -627,7 +627,7 @@ pub async fn get_conflict_policy(
627627
let result = client
628628
.get_raw(&format!("/v1/crdbs/{}/conflict_policy", id))
629629
.await
630-
.map_err(|e| RedisCtlError::from(e))?;
630+
.map_err(RedisCtlError::from)?;
631631

632632
let data = handle_output(result, output_format, query)?;
633633
print_formatted_output(data, output_format)?;
@@ -649,7 +649,7 @@ pub async fn update_conflict_policy(
649649
let result = client
650650
.put_raw(&format!("/v1/crdbs/{}/conflict_policy", id), policy_data)
651651
.await
652-
.map_err(|e| RedisCtlError::from(e))?;
652+
.map_err(RedisCtlError::from)?;
653653

654654
let data = handle_output(result, output_format, query)?;
655655
print_formatted_output(data, output_format)?;
@@ -677,7 +677,7 @@ pub async fn resolve_conflict(
677677
resolution_data,
678678
)
679679
.await
680-
.map_err(|e| RedisCtlError::from(e))?;
680+
.map_err(RedisCtlError::from)?;
681681

682682
let data = handle_output(result, output_format, query)?;
683683
print_formatted_output(data, output_format)?;
@@ -696,7 +696,7 @@ pub async fn get_crdb_connections(
696696
let result = client
697697
.get_raw(&format!("/v1/crdbs/{}/connections", id))
698698
.await
699-
.map_err(|e| RedisCtlError::from(e))?;
699+
.map_err(RedisCtlError::from)?;
700700

701701
let data = handle_output(result, output_format, query)?;
702702
print_formatted_output(data, output_format)?;
@@ -715,7 +715,7 @@ pub async fn get_crdb_throughput(
715715
let result = client
716716
.get_raw(&format!("/v1/crdbs/{}/throughput", id))
717717
.await
718-
.map_err(|e| RedisCtlError::from(e))?;
718+
.map_err(RedisCtlError::from)?;
719719

720720
let data = handle_output(result, output_format, query)?;
721721
print_formatted_output(data, output_format)?;
@@ -737,7 +737,7 @@ pub async fn backup_crdb(
737737
let result = client
738738
.post_raw(&format!("/v1/crdbs/{}/backup", id), backup_data)
739739
.await
740-
.map_err(|e| RedisCtlError::from(e))?;
740+
.map_err(RedisCtlError::from)?;
741741

742742
let data = handle_output(result, output_format, query)?;
743743
print_formatted_output(data, output_format)?;
@@ -759,7 +759,7 @@ pub async fn restore_crdb(
759759
let result = client
760760
.post_raw(&format!("/v1/crdbs/{}/restore", id), restore_data)
761761
.await
762-
.map_err(|e| RedisCtlError::from(e))?;
762+
.map_err(RedisCtlError::from)?;
763763

764764
let data = handle_output(result, output_format, query)?;
765765
print_formatted_output(data, output_format)?;
@@ -778,7 +778,7 @@ pub async fn get_crdb_backups(
778778
let result = client
779779
.get_raw(&format!("/v1/crdbs/{}/backups", id))
780780
.await
781-
.map_err(|e| RedisCtlError::from(e))?;
781+
.map_err(RedisCtlError::from)?;
782782

783783
let data = handle_output(result, output_format, query)?;
784784
print_formatted_output(data, output_format)?;
@@ -800,7 +800,7 @@ pub async fn export_crdb(
800800
let result = client
801801
.post_raw(&format!("/v1/crdbs/{}/export", id), export_data)
802802
.await
803-
.map_err(|e| RedisCtlError::from(e))?;
803+
.map_err(RedisCtlError::from)?;
804804

805805
let data = handle_output(result, output_format, query)?;
806806
print_formatted_output(data, output_format)?;

0 commit comments

Comments
 (0)