mirror of
https://github.com/MedzikUser/imgurs
synced 2024-08-15 00:03:19 +00:00
update logger
This commit is contained in:
parent
2c22737070
commit
461b53d681
7 changed files with 26 additions and 20 deletions
|
@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||
<!-- next-header -->
|
||||
|
||||
## [Unreleased]
|
||||
### CLI
|
||||
- update logger
|
||||
- added clipboard
|
||||
|
||||
## [0.3.0] - 2022-01-28
|
||||
### CLI
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
## 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
|
||||
|
||||
|
@ -18,6 +18,10 @@ imgurs completions zsh > /usr/local/share/zsh/site-functions/_imgurs
|
|||
imgurs completions fish > ~/.config/fish/completions/imgurs.fish
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
- **xsel** - support clipboard on Linux
|
||||
- **libnotify** - support notification on Linux
|
||||
|
||||
## How to install Imgurs CLI?
|
||||
|
||||
### **Linux**
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
use imgurs::api::{rate_limit::rate_limit, ImgurClient};
|
||||
|
||||
use colored::Colorize;
|
||||
use chrono::{prelude::DateTime, Utc};
|
||||
use log::info;
|
||||
use std::time::{Duration, UNIX_EPOCH};
|
||||
use imgurs::api::{rate_limit::rate_limit, ImgurClient};
|
||||
|
||||
pub async fn credits(client: ImgurClient) {
|
||||
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 datetime = DateTime::<Utc>::from(d);
|
||||
let date = UNIX_EPOCH + Duration::from_secs(i.data.user_reset.try_into().unwrap());
|
||||
let datetime = DateTime::<Utc>::from(date);
|
||||
let timestamp_str = datetime.format("%Y-%m-%d %H:%M:%S").to_string();
|
||||
|
||||
info!("User Limit {}", i.data.user_limit);
|
||||
info!("User Remaining {}", i.data.user_remaining);
|
||||
info!("User Reset {} (UTC)", timestamp_str);
|
||||
info!("Client Limit {}", i.data.client_limit);
|
||||
info!("Client Remaining {}", i.data.client_remaining);
|
||||
println!("{} {}", "user limit".green(), i.data.user_limit.to_string().magenta());
|
||||
println!("{} {}", "user remaining".green(), i.data.user_remaining.to_string().magenta());
|
||||
println!("{} {} {}", "user reset".green(), timestamp_str.magenta(), "(UTC)".blue());
|
||||
println!("{} {}", "client limit".green(), i.data.client_limit.to_string().magenta());
|
||||
println!("{} {}", "client remaining ".green(), i.data.client_remaining.to_string().magenta());
|
||||
}
|
||||
|
|
@ -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) {
|
||||
let i = del_img(client, delete_hash)
|
||||
.await
|
||||
.expect("send api request");
|
||||
info!("{i}");
|
||||
|
||||
println!("{}", i.magenta());
|
||||
}
|
||||
|
|
|
@ -3,6 +3,6 @@ use imgurs::api::{get_image::get_image, ImgurClient};
|
|||
use super::print_image_info;
|
||||
|
||||
pub async fn image_info(client: ImgurClient, id: &str) {
|
||||
let i = get_image(client, id).await.expect("send api request");
|
||||
print_image_info(i);
|
||||
let info = get_image(client, id).await.expect("send api request");
|
||||
print_image_info(info);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ pub mod parse;
|
|||
pub mod upload_image;
|
||||
|
||||
use imgurs::api::ImageInfo;
|
||||
|
||||
use chrono::{prelude::DateTime, Utc};
|
||||
use colored::Colorize;
|
||||
use std::time::{Duration, UNIX_EPOCH};
|
||||
|
|
|
@ -2,7 +2,6 @@ use imgurs::api::ImgurClient;
|
|||
|
||||
use clap::{Command, IntoApp, Parser, Subcommand};
|
||||
use clap_complete::{generate, Generator, Shell};
|
||||
use log::error;
|
||||
use std::io::stdout;
|
||||
|
||||
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),
|
||||
"powershell" => print_completions(Shell::PowerShell, &mut app),
|
||||
|
||||
_ => error!("Completions to shell `{shell}`, not found!"),
|
||||
_ => panic!("Completions to shell `{shell}`, not found!"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue