feat: 1.7.5, supports dialoguer
This commit is contained in:
41
Cargo.lock
generated
41
Cargo.lock
generated
@@ -474,6 +474,19 @@ dependencies = [
|
|||||||
"cipher",
|
"cipher",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dialoguer"
|
||||||
|
version = "0.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "658bce805d770f407bc62102fca7c2c64ceef2fbcb2b8bd19d2765ce093980de"
|
||||||
|
dependencies = [
|
||||||
|
"console",
|
||||||
|
"shell-words",
|
||||||
|
"tempfile",
|
||||||
|
"thiserror",
|
||||||
|
"zeroize",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "digest"
|
name = "digest"
|
||||||
version = "0.10.7"
|
version = "0.10.7"
|
||||||
@@ -581,6 +594,12 @@ dependencies = [
|
|||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fastrand"
|
||||||
|
version = "2.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ff"
|
name = "ff"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
@@ -1584,6 +1603,12 @@ dependencies = [
|
|||||||
"digest",
|
"digest",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "shell-words"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "signature"
|
name = "signature"
|
||||||
version = "2.2.0"
|
version = "2.2.0"
|
||||||
@@ -1705,6 +1730,19 @@ dependencies = [
|
|||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tempfile"
|
||||||
|
version = "3.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"fastrand",
|
||||||
|
"redox_syscall",
|
||||||
|
"rustix",
|
||||||
|
"windows-sys 0.52.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "term"
|
name = "term"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
@@ -1788,13 +1826,14 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tiny-encrypt"
|
name = "tiny-encrypt"
|
||||||
version = "1.7.4"
|
version = "1.7.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes-gcm-stream",
|
"aes-gcm-stream",
|
||||||
"base64",
|
"base64",
|
||||||
"chacha20-poly1305-stream",
|
"chacha20-poly1305-stream",
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
|
"dialoguer",
|
||||||
"flate2",
|
"flate2",
|
||||||
"fs-set-times",
|
"fs-set-times",
|
||||||
"hex",
|
"hex",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "tiny-encrypt"
|
name = "tiny-encrypt"
|
||||||
version = "1.7.4"
|
version = "1.7.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
description = "A simple and tiny file encrypt tool"
|
description = "A simple and tiny file encrypt tool"
|
||||||
@@ -50,6 +50,7 @@ pqcrypto-kyber = "0.8.0"
|
|||||||
pqcrypto-traits = "0.3.5"
|
pqcrypto-traits = "0.3.5"
|
||||||
pinentry = "0.5.0"
|
pinentry = "0.5.0"
|
||||||
secrecy = "0.8.0"
|
secrecy = "0.8.0"
|
||||||
|
dialoguer = "0.11.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
swift-rs = { path = "swift-rs", features = ["build"], optional = true }
|
swift-rs = { path = "swift-rs", features = ["build"], optional = true }
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ Environment
|
|||||||
| TINY_ENCRYPT_DEFAULT_COMPRESS | File compress, `1` or `on`, default `false` |
|
| TINY_ENCRYPT_DEFAULT_COMPRESS | File compress, `1` or `on`, default `false` |
|
||||||
| TINY_ENCRYPT_NO_PROGRESS | Do not display progress bar |
|
| TINY_ENCRYPT_NO_PROGRESS | Do not display progress bar |
|
||||||
| TINY_ENCRYPT_NO_DEFAULT_PIN_HINT | Do not display default PIN hint |
|
| TINY_ENCRYPT_NO_DEFAULT_PIN_HINT | Do not display default PIN hint |
|
||||||
|
| TINY_ENCRYPT_USE_DIALOGUER | Use dialoguer |
|
||||||
| TINY_ENCRYPT_PIN | PIV Card PIN |
|
| TINY_ENCRYPT_PIN | PIV Card PIN |
|
||||||
| TINY_ENCRYPT_KEY_ID | Default Key ID |
|
| TINY_ENCRYPT_KEY_ID | Default Key ID |
|
||||||
| TINY_ENCRYPT_AUTO_SELECT_KEY_IDS | Auto select Key IDs |
|
| TINY_ENCRYPT_AUTO_SELECT_KEY_IDS | Auto select Key IDs |
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ use std::process::Command;
|
|||||||
use std::time::{Instant, SystemTime};
|
use std::time::{Instant, SystemTime};
|
||||||
|
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
|
use dialoguer::Select;
|
||||||
|
use dialoguer::theme::ColorfulTheme;
|
||||||
use flate2::Compression;
|
use flate2::Compression;
|
||||||
use openpgp_card::crypto_data::Cryptogram;
|
use openpgp_card::crypto_data::Cryptogram;
|
||||||
use rust_util::{
|
use rust_util::{
|
||||||
@@ -743,11 +745,26 @@ pub fn select_envelop<'a>(meta: &'a TinyEncryptMeta, key_id: &Option<String>, co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO optimize select for exec-env
|
let use_dialoguer = util_env::get_use_dialoguer();
|
||||||
envelops.iter().enumerate().for_each(|(i, envelop)| {
|
let envelop_number = if use_dialoguer {
|
||||||
println_ex!("#{} {}", i + 1, util_envelop::format_envelop(envelop, config));
|
let format_envelops = envelops.iter().map(|envelop| {
|
||||||
});
|
format!("#{}", util_envelop::format_envelop(envelop, config))
|
||||||
let envelop_number = util::read_number("Please select an envelop:", 1, envelops.len());
|
}).collect::<Vec<_>>();
|
||||||
|
// TODO catch ctrl-c Term::show_cursor()
|
||||||
|
let select_result = Select::with_theme(&ColorfulTheme::default())
|
||||||
|
.with_prompt("Please select envelop: ")
|
||||||
|
.items(&format_envelops[..])
|
||||||
|
.default(0)
|
||||||
|
.report(false)
|
||||||
|
.clear(true)
|
||||||
|
.interact();
|
||||||
|
opt_result!(select_result, "Select envelop error: {}") + 1
|
||||||
|
} else {
|
||||||
|
envelops.iter().enumerate().for_each(|(i, envelop)| {
|
||||||
|
println_ex!("#{} {}", i + 1, util_envelop::format_envelop(envelop, config));
|
||||||
|
});
|
||||||
|
util::read_number("Please select an envelop:", 1, envelops.len())
|
||||||
|
};
|
||||||
|
|
||||||
let selected_envelop = &envelops[envelop_number - 1];
|
let selected_envelop = &envelops[envelop_number - 1];
|
||||||
if silent {
|
if silent {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use crate::consts;
|
|||||||
pub const TINY_ENCRYPT_ENV_DEFAULT_ALGORITHM: &str = "TINY_ENCRYPT_DEFAULT_ALGORITHM";
|
pub const TINY_ENCRYPT_ENV_DEFAULT_ALGORITHM: &str = "TINY_ENCRYPT_DEFAULT_ALGORITHM";
|
||||||
pub const TINY_ENCRYPT_ENV_DEFAULT_COMPRESS: &str = "TINY_ENCRYPT_DEFAULT_COMPRESS";
|
pub const TINY_ENCRYPT_ENV_DEFAULT_COMPRESS: &str = "TINY_ENCRYPT_DEFAULT_COMPRESS";
|
||||||
pub const TINY_ENCRYPT_ENV_NO_PROGRESS: &str = "TINY_ENCRYPT_NO_PROGRESS";
|
pub const TINY_ENCRYPT_ENV_NO_PROGRESS: &str = "TINY_ENCRYPT_NO_PROGRESS";
|
||||||
|
pub const TINY_ENCRYPT_ENV_USE_DIALOGUER: &str = "TINY_ENCRYPT_USE_DIALOGUER";
|
||||||
pub const TINY_ENCRYPT_ENV_PIN: &str = "TINY_ENCRYPT_PIN";
|
pub const TINY_ENCRYPT_ENV_PIN: &str = "TINY_ENCRYPT_PIN";
|
||||||
pub const TINY_ENCRYPT_ENV_KEY_ID: &str = "TINY_ENCRYPT_KEY_ID";
|
pub const TINY_ENCRYPT_ENV_KEY_ID: &str = "TINY_ENCRYPT_KEY_ID";
|
||||||
pub const TINY_ENCRYPT_ENV_AUTO_SELECT_KEY_IDS: &str = "TINY_ENCRYPT_AUTO_SELECT_KEY_IDS";
|
pub const TINY_ENCRYPT_ENV_AUTO_SELECT_KEY_IDS: &str = "TINY_ENCRYPT_AUTO_SELECT_KEY_IDS";
|
||||||
@@ -61,4 +62,8 @@ pub fn get_no_progress() -> bool {
|
|||||||
|
|
||||||
pub fn get_no_default_pin_hint() -> bool {
|
pub fn get_no_default_pin_hint() -> bool {
|
||||||
rust_util_env::is_env_on(TINY_ENCRYPT_ENV_NO_DEFAULT_PIN_HINT)
|
rust_util_env::is_env_on(TINY_ENCRYPT_ENV_NO_DEFAULT_PIN_HINT)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_use_dialoguer() -> bool {
|
||||||
|
rust_util_env::is_env_on(TINY_ENCRYPT_ENV_USE_DIALOGUER)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user