diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 79712a7..b23c318 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -22,6 +22,7 @@ chrono = "0.4.19" clap = "2.33.3" env_logger = "0.8.2" fuzzy-matcher = "0.3.7" +indicatif = "0.16.2" libjens = { git = "https://tilera.xyz/git/LordMZTE/libjens.git", rev = "d4a8b3" } log = "0.4.11" opener = "0.4.1" diff --git a/cli/src/commands/up.rs b/cli/src/commands/up.rs index e893c7b..8503bf6 100644 --- a/cli/src/commands/up.rs +++ b/cli/src/commands/up.rs @@ -1,9 +1,12 @@ use crate::util; use anyhow::{bail, Result}; +use indicatif::{ProgressBar, ProgressStyle}; use libjens::{api::UpResp, JMClient}; use log::info; -use reqwest::multipart::{Form, Part}; -use reqwest::Body; +use reqwest::{ + multipart::{Form, Part}, + Body, +}; use tokio::fs::File; use tokio_util::codec::{BytesCodec, FramedRead}; @@ -17,6 +20,21 @@ pub async fn run( ) -> Result<()> { util::assert_category_exists(client, &category).await?; + let spinner = ProgressBar::new_spinner(); + spinner.enable_steady_tick(50); + spinner.set_style(ProgressStyle::default_spinner().tick_strings(&[ + "🗎 JM", + " 🗎 JM", + " 🗎 JM", + " 🗎 JM", + " 🗎 JM", + " 🗎 JM", + " 🗎 JM", + " 🗎JM", + "▪▪▪▪▪▪▪▪▪▪", + ])); + spinner.set_message("Uploading..."); + let res = client .http .post("https://data.tilera.xyz/api/jensmemes/upload") @@ -43,6 +61,8 @@ pub async fn run( // TODO move into JMClient let bytes = &res.bytes().await?; + spinner.finish_with_message("Done!"); + let res = if let Ok(res) = serde_json::from_slice::(bytes) { res } else if let Ok(s) = std::str::from_utf8(bytes) {