about summary refs log tree commit diff
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/kittybox_bulk_import.rs8
-rw-r--r--src/bin/pyindieblog_to_kittybox.rs7
2 files changed, 7 insertions, 8 deletions
diff --git a/src/bin/kittybox_bulk_import.rs b/src/bin/kittybox_bulk_import.rs
index 652a4c2..a5252b7 100644
--- a/src/bin/kittybox_bulk_import.rs
+++ b/src/bin/kittybox_bulk_import.rs
@@ -1,4 +1,4 @@
-use std::io::{self, Read};
+use std::io;
 use std::fs::File;
 use anyhow::{anyhow, Context, Result, bail};
 
@@ -24,10 +24,10 @@ async fn main() -> Result<()> {
     let url = surf::Url::parse(&args[1])?;
     let client = surf::Client::new();
 
-    let mut iter = data.into_iter();
+    let iter = data.into_iter();
 
-    while let Some(post) = iter.next() {
-        println!("Processing {}...", post["properties"]["url"][0].as_str().or(post["properties"]["published"][0].as_str().or(post["properties"]["name"][0].as_str().or(Some("<unidentified post>")))).unwrap());
+    for post in iter {
+        println!("Processing {}...", post["properties"]["url"][0].as_str().or_else(|| post["properties"]["published"][0].as_str().or_else(|| post["properties"]["name"][0].as_str().or(Some("<unidentified post>")))).unwrap());
         match client.post(&url)
             .body(surf::http::Body::from_string(
                 serde_json::to_string(&post)?))
diff --git a/src/bin/pyindieblog_to_kittybox.rs b/src/bin/pyindieblog_to_kittybox.rs
index 7935da5..c932e0a 100644
--- a/src/bin/pyindieblog_to_kittybox.rs
+++ b/src/bin/pyindieblog_to_kittybox.rs
@@ -1,10 +1,9 @@
 use std::collections::HashMap;
 use std::fs::File;
-use anyhow::{Error, Result, Context, anyhow, bail};
+use anyhow::{Result, Context, anyhow};
 use mobc_redis::redis;
 use mobc_redis::redis::AsyncCommands;
 use serde::{Serialize, Deserialize};
-use serde_json::json;
 
 #[derive(Default, Serialize, Deserialize)]
 struct PyindieblogData {
@@ -16,10 +15,10 @@ struct PyindieblogData {
 async fn main() -> Result<()> {
     let mut args = std::env::args();
     args.next(); // skip argv[0] which is the name
-    let redis_uri = args.next().ok_or(anyhow!("No Redis URI provided"))?;
+    let redis_uri = args.next().ok_or_else(|| anyhow!("No Redis URI provided"))?;
     let client = redis::Client::open(redis_uri.as_str()).with_context(|| format!("Failed to construct Redis client on {}", redis_uri))?;
 
-    let filename = args.next().ok_or(anyhow!("No filename provided for export"))?;
+    let filename = args.next().ok_or_else(|| anyhow!("No filename provided for export"))?;
 
     let mut data: Vec<serde_json::Value>;