chore(release): v0.10.0

Add configuration for tls using features (rustls-tls or native-tls).
This commit is contained in:
MedzikUser 2022-10-01 18:43:08 +02:00
parent a66fea840a
commit 1bd632e906
No known key found for this signature in database
GPG Key ID: A5FAC1E185C112DB
11 changed files with 243 additions and 167 deletions

View File

@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
## [0.10.0] - 2022-10-01
- add configuration for tls (rustls-tls or native-tls)
## [0.9.1] - 2022-09-22
- delete debug info from cli in release build

273
Cargo.lock generated
View File

@ -2,15 +2,6 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "addr2line"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b"
dependencies = [
"gimli",
]
[[package]]
name = "adler"
version = "1.0.2"
@ -34,9 +25,9 @@ dependencies = [
[[package]]
name = "android_system_properties"
version = "0.1.4"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7ed72e1635e121ca3e79420540282af22da58be50de153d36f81ddc6b83aa9e"
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
dependencies = [
"libc",
]
@ -176,37 +167,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "backtrace"
version = "0.3.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61"
dependencies = [
"addr2line",
"cc",
"cfg-if",
"libc",
"miniz_oxide 0.5.3",
"object",
"rustc-demangle",
]
[[package]]
name = "base64"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
[[package]]
name = "better-panic"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fa9e1d11a268684cbd90ed36370d7577afb6c62d912ddff5c15fc34343e5036"
dependencies = [
"backtrace",
"console",
]
[[package]]
name = "bitflags"
version = "1.3.2"
@ -278,35 +244,33 @@ dependencies = [
[[package]]
name = "clap"
version = "3.2.20"
version = "4.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b71c3ce99b7611011217b366d923f1d0a7e07a92bb2dbf1e84508c673ca3bd"
checksum = "0a1af219c3e254a8b4649d6ddaef886b2015089f35f2ac5e1db31410c0566ab8"
dependencies = [
"atty",
"bitflags",
"clap_derive",
"clap_lex",
"indexmap",
"once_cell",
"strsim",
"termcolor",
"textwrap",
]
[[package]]
name = "clap_complete"
version = "3.2.4"
version = "4.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4179da71abd56c26b54dd0c248cc081c1f43b0a1a7e8448e28e57a29baa993d"
checksum = "11cba7abac9b56dfe2f035098cdb3a43946f276e6db83b72c4e692343f9aab9a"
dependencies = [
"clap",
]
[[package]]
name = "clap_derive"
version = "3.2.18"
version = "4.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65"
checksum = "cd114ae53ce5a0670f43d2f169c1cd26c69b4896b0c121900cf1e4d06d67316c"
dependencies = [
"heck 0.4.0",
"proc-macro-error",
@ -317,18 +281,18 @@ dependencies = [
[[package]]
name = "clap_lex"
version = "0.2.2"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5538cd660450ebeb4234cfecf8f2284b844ffc4c50531e66d584ad5b91293613"
checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
dependencies = [
"os_str_bytes",
]
[[package]]
name = "clap_mangen"
version = "0.1.11"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "105180c05a72388d5f5e4e4f6c79eecb92497bda749fa8f963a16647c5d5377f"
checksum = "d5d5cd261a1d5601621a7ee4870f6e7f3f1ba3fc901d867f5201b36691e7efbe"
dependencies = [
"clap",
"roff",
@ -371,19 +335,6 @@ dependencies = [
"cache-padded",
]
[[package]]
name = "console"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28b32d32ca44b70c3e4acd7db1babf555fa026e385fb95f18028f88848b3c31"
dependencies = [
"encode_unicode",
"libc",
"once_cell",
"terminal_size",
"winapi",
]
[[package]]
name = "core-foundation"
version = "0.9.3"
@ -502,12 +453,6 @@ version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6907e25393cdcc1f4f3f513d9aac1e840eb1cc341a0fccb01171f7d14d10b946"
[[package]]
name = "encode_unicode"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
[[package]]
name = "encoding_rs"
version = "0.8.31"
@ -677,12 +622,6 @@ dependencies = [
"wasi 0.11.0+wasi-snapshot-preview1",
]
[[package]]
name = "gimli"
version = "0.26.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4"
[[package]]
name = "h2"
version = "0.3.13"
@ -810,10 +749,23 @@ dependencies = [
]
[[package]]
name = "iana-time-zone"
version = "0.1.46"
name = "hyper-tls"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad2bfd338099682614d3ee3fe0cd72e0b6a41ca6a87f6a74a3bd593c91650501"
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
dependencies = [
"bytes",
"hyper",
"native-tls",
"tokio",
"tokio-native-tls",
]
[[package]]
name = "iana-time-zone"
version = "0.1.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd911b35d940d2bd0bea0f9100068e5b97b51a1cbe13d13382f132e0365257a0"
dependencies = [
"android_system_properties",
"core-foundation-sys",
@ -851,10 +803,9 @@ dependencies = [
[[package]]
name = "imgurs"
version = "0.9.1"
version = "0.10.0"
dependencies = [
"base64",
"notify-rust",
"reqwest",
"serde",
"serde_json",
@ -869,7 +820,6 @@ version = "0.9.1"
dependencies = [
"anyhow",
"arboard",
"better-panic",
"chrono",
"clap",
"clap_complete",
@ -1040,15 +990,6 @@ dependencies = [
"autocfg",
]
[[package]]
name = "miniz_oxide"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc"
dependencies = [
"adler",
]
[[package]]
name = "mio"
version = "0.8.4"
@ -1061,6 +1002,24 @@ dependencies = [
"windows-sys",
]
[[package]]
name = "native-tls"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9"
dependencies = [
"lazy_static",
"libc",
"log",
"openssl",
"openssl-probe",
"openssl-sys",
"schannel",
"security-framework",
"security-framework-sys",
"tempfile",
]
[[package]]
name = "nix"
version = "0.22.3"
@ -1190,21 +1149,57 @@ dependencies = [
"objc",
]
[[package]]
name = "object"
version = "0.28.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424"
dependencies = [
"memchr",
]
[[package]]
name = "once_cell"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225"
[[package]]
name = "openssl"
version = "0.10.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12fc0523e3bd51a692c8850d075d74dc062ccf251c0110668cbd921917118a13"
dependencies = [
"bitflags",
"cfg-if",
"foreign-types",
"libc",
"once_cell",
"openssl-macros",
"openssl-sys",
]
[[package]]
name = "openssl-macros"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "openssl-probe"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-sys"
version = "0.9.76"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5230151e44c0f05157effb743e8d517472843121cf9243e8b81393edb5acd9ce"
dependencies = [
"autocfg",
"cc",
"libc",
"pkg-config",
"vcpkg",
]
[[package]]
name = "ordered-stream"
version = "0.0.1"
@ -1293,6 +1288,12 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkg-config"
version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
[[package]]
name = "png"
version = "0.16.8"
@ -1360,9 +1361,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.39"
version = "1.0.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b"
dependencies = [
"unicode-ident",
]
@ -1468,12 +1469,14 @@ dependencies = [
"http-body",
"hyper",
"hyper-rustls",
"hyper-tls",
"ipnet",
"js-sys",
"lazy_static",
"log",
"mime",
"mime_guess",
"native-tls",
"percent-encoding",
"pin-project-lite",
"rustls",
@ -1482,6 +1485,7 @@ dependencies = [
"serde_json",
"serde_urlencoded",
"tokio",
"tokio-native-tls",
"tokio-rustls",
"tower-service",
"url",
@ -1513,12 +1517,6 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b833d8d034ea094b1ea68aa6d5c740e0d04bad9d16568d08ba6f76823a114316"
[[package]]
name = "rustc-demangle"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
[[package]]
name = "rustls"
version = "0.20.6"
@ -1546,6 +1544,16 @@ version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695"
[[package]]
name = "schannel"
version = "0.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2"
dependencies = [
"lazy_static",
"windows-sys",
]
[[package]]
name = "scopeguard"
version = "1.1.0"
@ -1562,6 +1570,29 @@ dependencies = [
"untrusted",
]
[[package]]
name = "security-framework"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c"
dependencies = [
"bitflags",
"core-foundation",
"core-foundation-sys",
"libc",
"security-framework-sys",
]
[[package]]
name = "security-framework-sys"
version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]]
name = "serde"
version = "1.0.144"
@ -1745,22 +1776,6 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "terminal_size"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "textwrap"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
[[package]]
name = "thiserror"
version = "1.0.34"
@ -1866,6 +1881,16 @@ dependencies = [
"syn",
]
[[package]]
name = "tokio-native-tls"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b"
dependencies = [
"native-tls",
"tokio",
]
[[package]]
name = "tokio-rustls"
version = "0.23.4"
@ -2023,6 +2048,12 @@ dependencies = [
"url",
]
[[package]]
name = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "version_check"
version = "0.9.4"

View File

@ -4,20 +4,21 @@ resolver = "2"
[package]
name = "imgurs"
version = "0.9.1"
version = "0.10.0"
description = "API for Imgur"
license = "BSD-3-Clause"
authors = ["MedzikUser <nivua1fn@duck.com>"]
authors = ["MedzikUser <medzik@duck.com>"]
homepage = "https://github.com/MedzikUser/imgurs"
repository = "https://github.com/MedzikUser/imgurs.git"
keywords = ["imgur", "imgur-api", "image", "image-upload"]
edition = "2021"
[features]
default = ["imgur"]
full = ["imgur", "null_pointer"]
default = ["imgur", "rustls-tls"]
full = ["imgur"]
rustls-tls = ["reqwest/rustls-tls"]
native-tls = ["reqwest/native-tls"]
imgur = []
null_pointer = []
[profile.release]
lto = true
@ -25,13 +26,18 @@ opt-level = 'z'
codegen-units = 1
[dependencies]
# HTTP
reqwest = { version = "0.11", default-features = false, features = ["json", "multipart"] }
# Request
base64 = "0.13"
notify-rust = "4.5"
validator = "0.16"
thiserror = "1.0"
serde_json = "1.0"
validator = "0.16" # validate url address
# Response
serde = { version = "1.0", features = ["derive"] }
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls", "multipart"] }
serde_json = "1.0"
# Errors
thiserror = "1.0"
[dev-dependencies]
# Async tests
tokio = { version = "1.21", features = ["macros", "rt-multi-thread"] }

View File

@ -3,7 +3,7 @@ name = "imgurs-cli"
version = "0.9.1"
description = "CLI for Imgur"
license = "BSD-3-Clause"
authors = ["MedzikUser <nivua1fn@duck.com>"]
authors = ["MedzikUser <medzik@duck.com>"]
homepage = "https://github.com/MedzikUser/imgurs"
repository = "https://github.com/MedzikUser/imgurs.git"
keywords = ["imgur", "imgur-api", "image", "image-upload"]
@ -15,21 +15,32 @@ name = "imgurs"
path = "src/main.rs"
[dependencies]
anyhow = "1.0"
clap = { version = "3.2", features = ["derive"] }
clap_complete = "3.2"
clap_mangen = "0.1"
chrono = "0.4"
colored = "2.0"
notify-rust = "4.5"
better-panic = "0.3"
dirs = "4.0"
simple_logger = "2.3"
toml = "0.5"
log = { version = "0.4", features = ["release_max_level_info"] }
serde = { version = "1.0", features = ["derive"] }
# Async runtime
tokio = { version = "1.21", features = ["macros", "rt-multi-thread"] }
imgurs = { path = "..", version = "0.9.0", features = ["full"] }
# CLI
clap = { version = "4.0", features = ["derive"] }
clap_complete = "4.0"
clap_mangen = "0.2"
# Errors
anyhow = "1.0"
# Logger
log = { version = "0.4", features = ["release_max_level_info"] }
simple_logger = "2.3"
colored = "2.0"
# Config
toml = "0.5"
serde = { version = "1.0", features = ["derive"] }
# Other
chrono = "0.4" # parse upload date
notify-rust = "4.5" # send notification after upload
dirs = "4.0" # get system configuration directory
imgurs = { path = "..", version = "0.10.0", features = ["full"] }
[target.'cfg(not(all(unix, not(any(target_os="macos", target_os="android", target_os="emscripten")))))'.dependencies]
arboard = "2.1"
arboard = "2.1" # copy url to clipboard

View File

@ -1,15 +1,16 @@
use super::Config;
use colored::Colorize;
use dirs::config_dir;
use log::warn;
use std::{
fs::{create_dir_all, read_to_string, File},
io::{self, Write as _},
path::Path,
};
use colored::Colorize;
use dirs::config_dir;
use log::warn;
use toml::from_str as toml_from_str;
use super::Config;
/// Configuration file path (in system config directory).
const CONFIG_DIR: &str = "/imgurs/config.toml";

View File

@ -4,12 +4,13 @@ mod delete_image;
mod info_image;
mod upload_image;
pub use self::{clipboard::*, credits::*, delete_image::*, info_image::*, upload_image::*};
use std::time::{Duration, UNIX_EPOCH};
use chrono::{prelude::DateTime, Utc};
use colored::Colorize;
use imgurs::ImageInfo;
use std::time::{Duration, UNIX_EPOCH};
pub use self::{clipboard::*, credits::*, delete_image::*, info_image::*, upload_image::*};
// print image information from imgur
pub fn print_image_info(i: &ImageInfo) {

View File

@ -1,18 +1,20 @@
use std::io::stdout;
use crate::imgur::*;
use clap::{Command, CommandFactory, Parser};
use clap_complete::{generate, Generator, Shell};
use imgurs::ImgurClient;
use simple_logger::SimpleLogger;
use crate::imgur::*;
mod config;
mod imgur;
#[derive(Parser, Debug)]
#[clap(
name = "imgurs",
about = "Imgur API CLI", long_about = None,
about = "Imgur API CLI",
long_about = env!("CARGO_PKG_DESCRIPTION"),
version = env!("CARGO_PKG_VERSION"),
)]
enum Cli {
@ -41,7 +43,6 @@ enum Cli {
#[tokio::main]
async fn main() {
SimpleLogger::new().init().unwrap();
better_panic::install();
// parse config file
let config = config::toml::parse();
@ -54,7 +55,7 @@ async fn main() {
match args {
Cli::Credits => credits(client).await,
Cli::Upload { path } => upload_image(client, path.to_string()).await,
Cli::Upload { path } => upload_image(client, path).await,
Cli::Delete { delete_hash } => delete_image(client, delete_hash.to_string()).await,
@ -68,14 +69,14 @@ async fn main() {
}
print_completions(shell, &mut app)
}
},
Cli::Manpage => {
let clap_app = Cli::command();
let man = clap_mangen::Man::new(clap_app);
man.render(&mut stdout())
.expect("failed to generate man page");
}
.expect("Failed to generate man page");
},
}
}

11
rustfmt.toml Normal file
View File

@ -0,0 +1,11 @@
# https://rust-lang.github.io/rustfmt
# stable
edition = "2021"
newline_style = "Unix"
match_block_trailing_comma = true
# nightly
group_imports = "StdExternalCrate"
imports_granularity = "Crate"
format_code_in_doc_comments = true

View File

@ -4,10 +4,9 @@ macro_rules! api_url (
);
);
pub(crate) use api_url;
use std::fmt;
pub(crate) use api_url;
use reqwest::Client;
/// Imgur Client

View File

@ -33,7 +33,10 @@ impl ImgurClient {
/// async fn main() {
/// let client = ImgurClient::new("3e3ce0d7ac14d56");
///
/// client.upload_image("https://i.imgur.com/lFaGr1x.png").await.expect("upload image");
/// client
/// .upload_image("https://i.imgur.com/lFaGr1x.png")
/// .await
/// .expect("upload image");
/// }
/// ```
pub async fn upload_image(&self, path: &str) -> Result<ImageInfo> {
@ -60,10 +63,16 @@ impl ImgurClient {
/// async fn main() {
/// let client = ImgurClient::new("3e3ce0d7ac14d56");
///
/// let image = client.upload_image("https://i.imgur.com/lFaGr1x.png").await.expect("upload image");
/// let image = client
/// .upload_image("https://i.imgur.com/lFaGr1x.png")
/// .await
/// .expect("upload image");
/// let deletehash = image.data.deletehash.unwrap();
///
/// client.delete_image(&deletehash).await.expect("delete image");
/// client
/// .delete_image(&deletehash)
/// .await
/// .expect("delete image");
/// }
/// ```
pub async fn delete_image(&self, delete_hash: &str) -> Result<()> {

View File

@ -40,7 +40,10 @@
//! let client = ImgurClient::new("client_id");
//!
//! // From URL
//! let info = client.upload_image("https://i.imgur.com/lFaGr1x.png").await.unwrap();
//! let info = client
//! .upload_image("https://i.imgur.com/lFaGr1x.png")
//! .await
//! .unwrap();
//! println!("{:?}", info);
//!
//! // From File