Skip to content

Commit

Permalink
fmt done
Browse files Browse the repository at this point in the history
Signed-off-by: Pushkar Mishra <[email protected]>
  • Loading branch information
Pushkarm029 committed Mar 23, 2024
1 parent b648096 commit 2cdd948
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions fs-storage/src/bin/cli.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use fs_storage::file_storage::FileStorage;
use serde_json::Value;
use std::collections::BTreeMap;
use std::env;
use std::path::Path;
use std::fs;
use fs_storage::file_storage::FileStorage;
use serde_json::Value;
use std::path::Path;

fn main() {
let args: Vec<String> = env::args().collect();
Expand Down Expand Up @@ -50,16 +50,21 @@ fn main() {
}

let json_file = &args[3];
let json_contents = fs::read_to_string(json_file).expect("Failed to read JSON file");
let json_value: Value = serde_json::from_str(&json_contents).expect("Invalid JSON");
let json_contents = fs::read_to_string(json_file)
.expect("Failed to read JSON file");
let json_value: Value =
serde_json::from_str(&json_contents).expect("Invalid JSON");

let mut kv_pairs = BTreeMap::new();
if let Value::Object(object) = json_value {
for (key, value) in object {
if let Value::String(value_str) = value {
kv_pairs.insert(key, value_str);
} else {
println!("Warning: Skipping non-string value for key '{}'", key);
println!(
"Warning: Skipping non-string value for key '{}'",
key
);
}
}
} else {
Expand Down

0 comments on commit 2cdd948

Please sign in to comment.