add spinner
continuous-integration/drone/push Build is passing Details

This commit is contained in:
LordMZTE 2021-08-21 22:12:26 +02:00
parent 92e452c473
commit 506fa02cd4
2 changed files with 23 additions and 2 deletions

View File

@ -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"

View File

@ -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::<UpResp>(bytes) {
res
} else if let Ok(s) = std::str::from_utf8(bytes) {