mirror of https://github.com/MedzikUser/imgurs
update
This commit is contained in:
parent
adc52ba207
commit
6c7c334ede
|
@ -43,3 +43,9 @@ jobs:
|
||||||
with:
|
with:
|
||||||
command: clippy
|
command: clippy
|
||||||
args: -- -D warnings
|
args: -- -D warnings
|
||||||
|
|
||||||
|
- name: rustfmt
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: fmt
|
||||||
|
args: -all --check
|
||||||
|
|
|
@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
### Library
|
### Library
|
||||||
- added Clone derive
|
- added Clone derive
|
||||||
|
- if body length is > 30 return body is too length
|
||||||
|
|
||||||
## [0.3.0] - 2022-01-28
|
## [0.3.0] - 2022-01-28
|
||||||
### CLI
|
### CLI
|
||||||
|
|
|
@ -18,6 +18,12 @@ 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
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Man page
|
||||||
|
|
||||||
|
Generate manpage
|
||||||
|
|
||||||
|
imgurs manpage | gzip > /usr/share/man/man1/imgurs.1.gz
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
- support clipboard on Linux
|
- support clipboard on Linux
|
||||||
- **xsel**
|
- **xsel**
|
||||||
|
@ -38,7 +44,7 @@ Using yay ([AUR](https://aur.archlinux.org/packages/imgurs))
|
||||||
|
|
||||||
yay -S imgurs
|
yay -S imgurs
|
||||||
|
|
||||||
If you are using arch linux you can add [this repo](https://github.com/archlinux-pkg/packages) and run
|
or can add [this repo](https://github.com/archlinux-pkg/packages) and run
|
||||||
|
|
||||||
sudo pacman -Sy imgurs
|
sudo pacman -Sy imgurs
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
pub struct ImageInfo {
|
pub struct ImageInfo {
|
||||||
pub data: ImageInfoData,
|
pub data: ImageInfoData,
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
pub status: i32,
|
pub status: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
pub struct ImageInfoData {
|
pub struct ImageInfoData {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub title: Option<String>,
|
pub title: Option<String>,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
mod image_type;
|
mod image_type;
|
||||||
mod send_request;
|
|
||||||
|
|
||||||
pub mod configuration;
|
pub mod configuration;
|
||||||
pub mod delete_image;
|
pub mod delete_image;
|
||||||
|
@ -9,4 +8,34 @@ pub mod upload_image;
|
||||||
|
|
||||||
pub use configuration::ImgurClient;
|
pub use configuration::ImgurClient;
|
||||||
pub use image_type::*;
|
pub use image_type::*;
|
||||||
pub use send_request::send_api_request;
|
|
||||||
|
use reqwest::Method;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
pub async fn send_api_request(
|
||||||
|
config: &ImgurClient,
|
||||||
|
method: Method,
|
||||||
|
uri: String,
|
||||||
|
form: Option<HashMap<&str, String>>,
|
||||||
|
) -> Result<reqwest::Response, anyhow::Error> {
|
||||||
|
let client = &config.client;
|
||||||
|
|
||||||
|
let mut req = client.request(method, uri.as_str());
|
||||||
|
|
||||||
|
const VERSION: Option<&str> = option_env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
|
req = req
|
||||||
|
.header("Authorization", format!("Client-ID {}", config.client_id))
|
||||||
|
.header(
|
||||||
|
"User-Agent",
|
||||||
|
format!("Imgur/{:?}", VERSION.unwrap_or("unknown")),
|
||||||
|
);
|
||||||
|
|
||||||
|
if form != None {
|
||||||
|
req = req.form(&form.unwrap())
|
||||||
|
}
|
||||||
|
|
||||||
|
let req = req.build()?;
|
||||||
|
|
||||||
|
client.execute(req).await.map_err(anyhow::Error::from)
|
||||||
|
}
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
use super::ImgurClient;
|
|
||||||
|
|
||||||
use anyhow::Error;
|
|
||||||
use reqwest::Method;
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
pub async fn send_api_request(
|
|
||||||
config: &ImgurClient,
|
|
||||||
method: Method,
|
|
||||||
uri: String,
|
|
||||||
form: Option<HashMap<&str, String>>,
|
|
||||||
) -> Result<reqwest::Response, Error> {
|
|
||||||
let client = &config.client;
|
|
||||||
|
|
||||||
let mut req = client.request(method, uri.as_str());
|
|
||||||
|
|
||||||
const VERSION: Option<&str> = option_env!("CARGO_PKG_VERSION");
|
|
||||||
|
|
||||||
req = req
|
|
||||||
.header("Authorization", format!("Client-ID {}", config.client_id))
|
|
||||||
.header(
|
|
||||||
"User-Agent",
|
|
||||||
format!("Imgur/{:?}", VERSION.unwrap_or("unknown")),
|
|
||||||
);
|
|
||||||
|
|
||||||
if form != None {
|
|
||||||
req = req.form(&form.unwrap())
|
|
||||||
}
|
|
||||||
|
|
||||||
let req = req.build()?;
|
|
||||||
|
|
||||||
client.execute(req).await.map_err(Error::from)
|
|
||||||
}
|
|
Loading…
Reference in New Issue