mirror of https://github.com/MedzikUser/imgurs
rustfmt
This commit is contained in:
parent
bfb10f5274
commit
4145e7e86b
|
@ -1,5 +1,5 @@
|
|||
use std::fmt;
|
||||
use reqwest::Client;
|
||||
use std::fmt;
|
||||
|
||||
macro_rules! api_url (
|
||||
($path: expr) => (
|
||||
|
@ -25,7 +25,7 @@ impl ImgurHandle {
|
|||
let client = Client::new();
|
||||
ImgurHandle {
|
||||
client_id: client_id,
|
||||
client: client
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,9 @@ pub async fn delete_image(c: ImgurHandle, delete_hash: String) -> Result<String,
|
|||
|
||||
if status.is_client_error() || status.is_server_error() {
|
||||
let body = res.text().await.map_err(|err| err.to_string())?;
|
||||
Err(format!("server returned non-successful status code = {status}. body = {body}"))
|
||||
Err(format!(
|
||||
"server returned non-successful status code = {status}. body = {body}"
|
||||
))
|
||||
} else {
|
||||
Ok("If the delete hash was correct the image was deleted!".to_string())
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub mod rate_limit;
|
||||
pub mod configuration;
|
||||
pub mod upload_image;
|
||||
pub mod delete_image;
|
||||
pub mod rate_limit;
|
||||
pub mod upload_image;
|
||||
|
|
|
@ -40,7 +40,9 @@ pub async fn rate_limit(c: ImgurHandle) -> Result<RateLimitInfo, String> {
|
|||
|
||||
if status.is_client_error() || status.is_server_error() {
|
||||
let body = res.text().await.map_err(|err| err.to_string())?;
|
||||
Err(format!("server returned non-successful status code = {status}. body = {body}"))
|
||||
Err(format!(
|
||||
"server returned non-successful status code = {status}. body = {body}"
|
||||
))
|
||||
} else {
|
||||
let content: RateLimitInfo = res.json().await.map_err(|err| err.to_string())?;
|
||||
Ok(content)
|
||||
|
|
|
@ -51,7 +51,9 @@ pub async fn upload_image(c: ImgurHandle, image: &str) -> Result<ImageInfo, Stri
|
|||
|
||||
if status.is_client_error() || status.is_server_error() {
|
||||
let body = res.text().await.map_err(|err| err.to_string())?;
|
||||
Err(format!("server returned non-successful status code = {status}. body = {body}"))
|
||||
Err(format!(
|
||||
"server returned non-successful status code = {status}. body = {body}"
|
||||
))
|
||||
} else {
|
||||
let content: ImageInfo = res.json().await.map_err(|err| err.to_string())?;
|
||||
Ok(content)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use clap::{Parser, Subcommand, AppSettings};
|
||||
use clap::{AppSettings, Parser, Subcommand};
|
||||
|
||||
use imgurs::api::configuration::ImgurHandle;
|
||||
|
||||
|
@ -26,17 +26,13 @@ enum Commands {
|
|||
setting(AppSettings::ArgRequiredElseHelp),
|
||||
about = "Upload image to imgur"
|
||||
)]
|
||||
Upload {
|
||||
path: String
|
||||
},
|
||||
Upload { path: String },
|
||||
|
||||
#[clap(
|
||||
setting(AppSettings::ArgRequiredElseHelp),
|
||||
about = "Upload image to imgur"
|
||||
)]
|
||||
Delete {
|
||||
delete_hash: String
|
||||
},
|
||||
Delete { delete_hash: String },
|
||||
}
|
||||
|
||||
pub async fn parse(client: ImgurHandle) {
|
||||
|
@ -44,18 +40,15 @@ pub async fn parse(client: ImgurHandle) {
|
|||
|
||||
match &args.command {
|
||||
Commands::Credits => {
|
||||
credits::credits(client)
|
||||
.await;
|
||||
credits::credits(client).await;
|
||||
}
|
||||
|
||||
Commands::Upload { path } => {
|
||||
upload_image::upload_image(client, path)
|
||||
.await;
|
||||
upload_image::upload_image(client, path).await;
|
||||
}
|
||||
|
||||
Commands::Delete { delete_hash } => {
|
||||
delete_image::delete_image(client, delete_hash.to_string())
|
||||
.await;
|
||||
delete_image::delete_image(client, delete_hash.to_string()).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use imgurs::api::configuration::ImgurHandle;
|
||||
use imgurs::api::rate_limit::*;
|
||||
|
||||
use log::{info, error};
|
||||
use log::{error, info};
|
||||
|
||||
use chrono::prelude::DateTime;
|
||||
use chrono::Utc;
|
||||
use std::time::{UNIX_EPOCH, Duration};
|
||||
use std::time::{Duration, UNIX_EPOCH};
|
||||
|
||||
pub async fn credits(client: ImgurHandle) {
|
||||
match rate_limit(client).await {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use imgurs::api::configuration::ImgurHandle;
|
||||
use imgurs::api;
|
||||
use imgurs::api::configuration::ImgurHandle;
|
||||
|
||||
use log::{info, error};
|
||||
use log::{error, info};
|
||||
|
||||
pub async fn delete_image(client: ImgurHandle, delete_hash: String) {
|
||||
match api::delete_image::delete_image(client, delete_hash).await {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub mod cli;
|
||||
pub mod credits;
|
||||
pub mod upload_image;
|
||||
pub mod delete_image;
|
||||
pub mod upload_image;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use imgurs::api::configuration::ImgurHandle;
|
||||
|
||||
use log::{info, error};
|
||||
use std::path::Path;
|
||||
use std::fs;
|
||||
use base64;
|
||||
use log::{error, info};
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
use chrono::prelude::DateTime;
|
||||
use chrono::Utc;
|
||||
use std::time::{UNIX_EPOCH, Duration};
|
||||
use std::time::{Duration, UNIX_EPOCH};
|
||||
|
||||
pub async fn upload_image(client: ImgurHandle, path: &str) {
|
||||
let image: String;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use toml::from_str;
|
||||
use serde_derive::Deserialize;
|
||||
use dirs::config_dir;
|
||||
use serde_derive::Deserialize;
|
||||
use std::fs::read_to_string;
|
||||
use toml::from_str;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct Config {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
mod config;
|
||||
mod cli;
|
||||
mod config;
|
||||
|
||||
use cli::cli::parse;
|
||||
|
||||
|
|
Loading…
Reference in New Issue