update logger

This commit is contained in:
Medzik 2022-02-27 11:39:02 +01:00
parent 2c22737070
commit 461b53d681
No known key found for this signature in database
GPG Key ID: A5FAC1E185C112DB
7 changed files with 26 additions and 20 deletions

View File

@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
<!-- next-header --> <!-- next-header -->
## [Unreleased] ## [Unreleased]
### CLI
- update logger
- added clipboard
## [0.3.0] - 2022-01-28 ## [0.3.0] - 2022-01-28
### CLI ### CLI

View File

@ -2,9 +2,9 @@
## Screenshots ## Screenshots
![upload](https://cdn.magicuser.cf/tcqqxEh.png) ![upload](https://cdn.magicuser.cf/7eMaL5d.png)
![delete](https://cdn.magicuser.cf/hBqbsIm.png) ![delete](https://cdn.magicuser.cf/TSxBrhO.png)
## Shell completions ## Shell completions
@ -18,6 +18,10 @@ imgurs completions zsh > /usr/local/share/zsh/site-functions/_imgurs
imgurs completions fish > ~/.config/fish/completions/imgurs.fish imgurs completions fish > ~/.config/fish/completions/imgurs.fish
``` ```
## Dependencies
- **xsel** - support clipboard on Linux
- **libnotify** - support notification on Linux
## How to install Imgurs CLI? ## How to install Imgurs CLI?
### **Linux** ### **Linux**

View File

@ -1,19 +1,19 @@
use imgurs::api::{rate_limit::rate_limit, ImgurClient}; use colored::Colorize;
use chrono::{prelude::DateTime, Utc}; use chrono::{prelude::DateTime, Utc};
use log::info;
use std::time::{Duration, UNIX_EPOCH}; use std::time::{Duration, UNIX_EPOCH};
use imgurs::api::{rate_limit::rate_limit, ImgurClient};
pub async fn credits(client: ImgurClient) { pub async fn credits(client: ImgurClient) {
let i = rate_limit(client).await.expect("send api request"); let i = rate_limit(client).await.expect("send api request");
let d = UNIX_EPOCH + Duration::from_secs(i.data.user_reset.try_into().unwrap()); let date = UNIX_EPOCH + Duration::from_secs(i.data.user_reset.try_into().unwrap());
let datetime = DateTime::<Utc>::from(d); let datetime = DateTime::<Utc>::from(date);
let timestamp_str = datetime.format("%Y-%m-%d %H:%M:%S").to_string(); let timestamp_str = datetime.format("%Y-%m-%d %H:%M:%S").to_string();
info!("User Limit {}", i.data.user_limit); println!("{} {}", "user limit".green(), i.data.user_limit.to_string().magenta());
info!("User Remaining {}", i.data.user_remaining); println!("{} {}", "user remaining".green(), i.data.user_remaining.to_string().magenta());
info!("User Reset {} (UTC)", timestamp_str); println!("{} {} {}", "user reset".green(), timestamp_str.magenta(), "(UTC)".blue());
info!("Client Limit {}", i.data.client_limit); println!("{} {}", "client limit".green(), i.data.client_limit.to_string().magenta());
info!("Client Remaining {}", i.data.client_remaining); println!("{} {}", "client remaining ".green(), i.data.client_remaining.to_string().magenta());
} }

View File

@ -1,10 +1,11 @@
use imgurs::api::{delete_image::delete_image as del_img, ImgurClient}; use colored::Colorize;
use log::info; use imgurs::api::{delete_image::delete_image as del_img, ImgurClient};
pub async fn delete_image(client: ImgurClient, delete_hash: String) { pub async fn delete_image(client: ImgurClient, delete_hash: String) {
let i = del_img(client, delete_hash) let i = del_img(client, delete_hash)
.await .await
.expect("send api request"); .expect("send api request");
info!("{i}");
println!("{}", i.magenta());
} }

View File

@ -3,6 +3,6 @@ use imgurs::api::{get_image::get_image, ImgurClient};
use super::print_image_info; use super::print_image_info;
pub async fn image_info(client: ImgurClient, id: &str) { pub async fn image_info(client: ImgurClient, id: &str) {
let i = get_image(client, id).await.expect("send api request"); let info = get_image(client, id).await.expect("send api request");
print_image_info(i); print_image_info(info);
} }

View File

@ -6,7 +6,6 @@ pub mod parse;
pub mod upload_image; pub mod upload_image;
use imgurs::api::ImageInfo; use imgurs::api::ImageInfo;
use chrono::{prelude::DateTime, Utc}; use chrono::{prelude::DateTime, Utc};
use colored::Colorize; use colored::Colorize;
use std::time::{Duration, UNIX_EPOCH}; use std::time::{Duration, UNIX_EPOCH};

View File

@ -2,7 +2,6 @@ use imgurs::api::ImgurClient;
use clap::{Command, IntoApp, Parser, Subcommand}; use clap::{Command, IntoApp, Parser, Subcommand};
use clap_complete::{generate, Generator, Shell}; use clap_complete::{generate, Generator, Shell};
use log::error;
use std::io::stdout; use std::io::stdout;
use crate::cli::{credits::*, delete_image::*, info_image::*, upload_image::*}; use crate::cli::{credits::*, delete_image::*, info_image::*, upload_image::*};
@ -72,7 +71,7 @@ pub async fn parse(client: ImgurClient) {
"fish" => print_completions(Shell::Fish, &mut app), "fish" => print_completions(Shell::Fish, &mut app),
"powershell" => print_completions(Shell::PowerShell, &mut app), "powershell" => print_completions(Shell::PowerShell, &mut app),
_ => error!("Completions to shell `{shell}`, not found!"), _ => panic!("Completions to shell `{shell}`, not found!"),
} }
} }
} }