mirror of https://github.com/MedzikUser/imgurs
update
This commit is contained in:
parent
71d124f435
commit
f26170bc12
|
@ -1,20 +0,0 @@
|
|||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = false
|
||||
|
||||
[*.yml]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = false
|
|
@ -135,9 +135,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "async-task"
|
||||
version = "4.2.0"
|
||||
version = "4.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30696a84d817107fc028e049980e09d5e140e8da8f1caeb17e8e950658a3cea9"
|
||||
checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524"
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
|
@ -938,7 +938,7 @@ dependencies = [
|
|||
"dirs-next",
|
||||
"objc-foundation",
|
||||
"objc_id",
|
||||
"time 0.3.9",
|
||||
"time 0.3.11",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1759,9 +1759,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.9"
|
||||
version = "0.3.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2702e08a7a860f005826c6815dcac101b19b5eb330c27fe4a5928fec1d20ddd"
|
||||
checksum = "72c91f41dcb2f096c05f0873d667dceec1087ce5bcf984ec8ffb19acddbb3217"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"num_threads",
|
||||
|
@ -1865,9 +1865,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.21"
|
||||
version = "0.1.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc6b8ad3567499f98a1db7a752b07a7c8c7c7c34c332ec00effb2b0027974b7c"
|
||||
checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -2262,9 +2262,9 @@ checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3"
|
|||
|
||||
[[package]]
|
||||
name = "zbus"
|
||||
version = "2.3.1"
|
||||
version = "2.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79fa581173f081cddb0a5fdf5bd93a1c2e0d18f912e877abeac345cc506438ad"
|
||||
checksum = "2d8f1a037b2c4a67d9654dc7bdfa8ff2e80555bbefdd3c1833c1d1b27c963a6b"
|
||||
dependencies = [
|
||||
"async-broadcast",
|
||||
"async-channel",
|
||||
|
@ -2302,9 +2302,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "zbus_macros"
|
||||
version = "2.3.1"
|
||||
version = "2.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1aeebcf4bcee4668f64e1de231464a81ace79dd651cbe1b567007b48ad31862"
|
||||
checksum = "1f8fb5186d1c87ae88cf234974c240671238b4a679158ad3b94ec465237349a6"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
|
@ -2326,9 +2326,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "zvariant"
|
||||
version = "3.3.0"
|
||||
version = "3.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e374c6fc8c84bd5392281285ec9ac003b0a1159d985d8e93ea17c8796d03354d"
|
||||
checksum = "cf2c71467724d4a77f0a1f0339dab10ca5d63f6a82411289cdcdfbfd47d2e407"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"enumflags2",
|
||||
|
@ -2340,9 +2340,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "zvariant_derive"
|
||||
version = "3.3.0"
|
||||
version = "3.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af4062552b13f1097b5e53ac7369c34efee5912fdc19c76805244f5e4ed5fa0e"
|
||||
checksum = "2c47f3630ce926a03abf21f5a8db90c60c81ed71599b5c86ad1a54fd3c7564c5"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
|
|
|
@ -21,7 +21,6 @@ codegen-units = 1
|
|||
[dependencies]
|
||||
dirs = "4.0.0"
|
||||
toml = "0.5.9"
|
||||
serde_json = "1.0.82"
|
||||
chrono = "0.4.19"
|
||||
base64 = "0.13.0"
|
||||
notify-rust = "4.5.8"
|
||||
|
@ -32,6 +31,7 @@ validator = "0.15.0"
|
|||
colored = "2.0.0"
|
||||
clap_mangen = "0.1.10"
|
||||
thiserror = "1.0.31"
|
||||
serde_json = "1.0.82"
|
||||
serde = { version = "1.0.138", features = ["derive"] }
|
||||
clap = { version = "3.2.8", features = ["derive"] }
|
||||
log = { version = "0.4.17", features = ["release_max_level_info", "max_level_debug"] }
|
||||
|
|
|
@ -13,7 +13,7 @@ use reqwest::Client;
|
|||
/// Imgur Client
|
||||
#[derive(Clone)]
|
||||
pub struct ImgurClient {
|
||||
/// Client id for a Imgur API
|
||||
/// Imgur API Client ID
|
||||
pub client_id: String,
|
||||
/// HTTP Client
|
||||
pub client: Client,
|
||||
|
|
|
@ -12,9 +12,9 @@ pub enum Error {
|
|||
/// Invalid file path or URL adress
|
||||
#[error("{0} is not url or file path")]
|
||||
InvalidUrlOrFile(String),
|
||||
/// reqwest::Error
|
||||
#[error("reqwest error - {0}")]
|
||||
ReqwestError(reqwest::Error),
|
||||
/// Imgur API error or reqwest::Error
|
||||
#[error("send request to imgur api: {0}")]
|
||||
SendApiRequest(reqwest::Error),
|
||||
/// std::io::Error
|
||||
#[error("io error - {0}")]
|
||||
IoError(std::io::Error),
|
||||
|
@ -22,7 +22,7 @@ pub enum Error {
|
|||
|
||||
impl From<reqwest::Error> for Error {
|
||||
fn from(err: reqwest::Error) -> Self {
|
||||
Error::ReqwestError(err)
|
||||
Error::SendApiRequest(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,25 +2,36 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
pub mod toml;
|
||||
|
||||
/// Configuration schema
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Config {
|
||||
/// Imgur API configuration options
|
||||
pub imgur: ConfigImgur,
|
||||
/// Notification options
|
||||
pub notification: ConfigNotification,
|
||||
/// Clipboard options
|
||||
pub clipboard: ConfigClipboard,
|
||||
}
|
||||
|
||||
/// Imgur API configuration options
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct ConfigImgur {
|
||||
/// Imgur Client ID
|
||||
pub id: String,
|
||||
/// Imgur Domain (e.g. if you have a imgur proxy)
|
||||
pub image_cdn: String,
|
||||
}
|
||||
|
||||
/// Notification options
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct ConfigNotification {
|
||||
/// Send notification
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
/// Clipboard options
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct ConfigClipboard {
|
||||
/// Copy image url to clipboard
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
|
|
@ -10,9 +10,12 @@ use std::{
|
|||
};
|
||||
use toml::from_str as toml_from_str;
|
||||
|
||||
/// Configuration file path (in system config directory).
|
||||
const CONFIG_DIR: &str = "/imgurs/config.toml";
|
||||
|
||||
/// Parse configuration file
|
||||
pub fn parse() -> Config {
|
||||
// parse config or use default
|
||||
toml().unwrap_or_else(|err| {
|
||||
let mut stdout = std::io::stdout();
|
||||
|
||||
|
@ -44,7 +47,7 @@ pub fn parse() -> Config {
|
|||
|
||||
toml().expect("parse toml config")
|
||||
} else {
|
||||
panic!("New config creation cancelled!")
|
||||
panic!("Configuration file creation cancelled!")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue