diff --git a/Cargo.lock b/Cargo.lock
index 874e505..2244aab 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -211,7 +211,7 @@ dependencies = [
"futures-lite 2.3.0",
"parking",
"polling 3.7.3",
- "rustix 0.38.34",
+ "rustix 0.38.35",
"slab",
"tracing",
"windows-sys 0.59.0",
@@ -250,7 +250,7 @@ dependencies = [
"cfg-if",
"event-listener 3.1.0",
"futures-lite 1.13.0",
- "rustix 0.38.34",
+ "rustix 0.38.35",
"windows-sys 0.48.0",
]
@@ -277,7 +277,7 @@ dependencies = [
"cfg-if",
"futures-core",
"futures-io",
- "rustix 0.38.34",
+ "rustix 0.38.35",
"signal-hook-registry",
"slab",
"windows-sys 0.59.0",
@@ -560,9 +560,9 @@ dependencies = [
[[package]]
name = "cc"
-version = "1.1.14"
+version = "1.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "50d2eb3cd3d1bf4529e31c215ee6f93ec5a3d536d9f578f93d9d33ee19562932"
+checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6"
dependencies = [
"jobserver",
"libc",
@@ -671,14 +671,14 @@ dependencies = [
"anstyle",
"clap_lex",
"strsim 0.11.1",
- "terminal_size 0.3.0",
+ "terminal_size",
]
[[package]]
name = "clap_complete"
-version = "4.5.23"
+version = "4.5.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "531d7959c5bbb6e266cecdd0f20213639c3a5c3e4d615f97db87661745f781ff"
+checksum = "6d7db6eca8c205649e8d3ccd05aa5042b1800a784e56bc7c43524fde8abbfa9b"
dependencies = [
"clap",
]
@@ -774,19 +774,6 @@ dependencies = [
"crossbeam-utils",
]
-[[package]]
-name = "console"
-version = "0.15.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb"
-dependencies = [
- "encode_unicode",
- "lazy_static",
- "libc",
- "unicode-width",
- "windows-sys 0.52.0",
-]
-
[[package]]
name = "const-oid"
version = "0.9.6"
@@ -1309,12 +1296,6 @@ dependencies = [
"serde",
]
-[[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.34"
@@ -1463,9 +1444,9 @@ checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d"
[[package]]
name = "filetime"
-version = "0.2.24"
+version = "0.2.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bf401df4a4e3872c4fe8151134cf483738e74b67fc934d6532c882b3d24a4550"
+checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586"
dependencies = [
"cfg-if",
"libc",
@@ -1910,13 +1891,11 @@ dependencies = [
"clap_mangen",
"color-eyre",
"comfy-table",
- "console",
"crossterm 0.27.0",
"dirs 4.0.0",
"email-lib",
"email_address",
"erased-serde",
- "indicatif",
"inquire",
"mail-builder",
"md5",
@@ -1924,6 +1903,7 @@ dependencies = [
"oauth-lib",
"once_cell",
"petgraph",
+ "pimalaya-tui",
"process-lib",
"secret-lib",
"serde",
@@ -1931,14 +1911,12 @@ dependencies = [
"serde_json",
"shellexpand-utils",
"sled",
- "terminal_size 0.1.17",
"tokio",
"toml",
"toml_edit 0.22.20",
"tracing",
"tracing-error",
"tracing-subscriber",
- "unicode-width",
"url",
"uuid",
]
@@ -2121,7 +2099,7 @@ dependencies = [
"hyper-util",
"log",
"rustls 0.23.12",
- "rustls-native-certs 0.7.2",
+ "rustls-native-certs 0.7.3",
"rustls-pki-types",
"tokio",
"tokio-rustls 0.26.0",
@@ -2213,7 +2191,7 @@ source = "git+https://github.com/pimalaya/imap-client#02d6bce5513c8ec6ac3aff0e7b
dependencies = [
"imap-next",
"once_cell",
- "rustls-native-certs 0.7.2",
+ "rustls-native-certs 0.7.3",
"thiserror",
"tokio",
"tokio-rustls 0.26.0",
@@ -2223,7 +2201,7 @@ dependencies = [
[[package]]
name = "imap-codec"
version = "2.0.0-alpha.4"
-source = "git+https://github.com/duesee/imap-codec#fff8355ad0f7133be9e58919be5a6f05f684d421"
+source = "git+https://github.com/duesee/imap-codec#95de04494f89464a59c114859217e6119a18d426"
dependencies = [
"abnf-core",
"base64 0.22.1",
@@ -2250,7 +2228,7 @@ dependencies = [
[[package]]
name = "imap-types"
version = "2.0.0-alpha.3"
-source = "git+https://github.com/duesee/imap-codec#fff8355ad0f7133be9e58919be5a6f05f684d421"
+source = "git+https://github.com/duesee/imap-codec#95de04494f89464a59c114859217e6119a18d426"
dependencies = [
"base64 0.22.1",
"bounded-static",
@@ -2276,19 +2254,6 @@ dependencies = [
"hashbrown",
]
-[[package]]
-name = "indicatif"
-version = "0.17.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3"
-dependencies = [
- "console",
- "instant",
- "number_prefix",
- "portable-atomic",
- "unicode-width",
-]
-
[[package]]
name = "inotify"
version = "0.9.6"
@@ -2938,12 +2903,6 @@ dependencies = [
"libm",
]
-[[package]]
-name = "number_prefix"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
-
[[package]]
name = "oauth-lib"
version = "0.1.1"
@@ -3240,6 +3199,22 @@ dependencies = [
"z-base-32",
]
+[[package]]
+name = "pimalaya-tui"
+version = "0.1.0"
+source = "git+https://github.com/pimalaya/tui#80660dfaf9daafbaa716c711e510bf3cfd04cd69"
+dependencies = [
+ "crossterm 0.25.0",
+ "dirs 4.0.0",
+ "email-lib",
+ "email_address",
+ "inquire",
+ "oauth-lib",
+ "secret-lib",
+ "shellexpand-utils",
+ "thiserror",
+]
+
[[package]]
name = "pin-project"
version = "1.1.5"
@@ -3336,17 +3311,11 @@ dependencies = [
"concurrent-queue",
"hermit-abi 0.4.0",
"pin-project-lite",
- "rustix 0.38.34",
+ "rustix 0.38.35",
"tracing",
"windows-sys 0.59.0",
]
-[[package]]
-name = "portable-atomic"
-version = "1.7.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265"
-
[[package]]
name = "ppv-lite86"
version = "0.2.20"
@@ -3358,9 +3327,9 @@ dependencies = [
[[package]]
name = "prettyplease"
-version = "0.2.21"
+version = "0.2.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a909e6e8053fa1a5ad670f5816c7d93029ee1fa8898718490544a6b0d5d38b3e"
+checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba"
dependencies = [
"proc-macro2",
"syn 2.0.76",
@@ -3710,9 +3679,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustc_version"
-version = "0.4.0"
+version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
+checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
dependencies = [
"semver",
]
@@ -3733,9 +3702,9 @@ dependencies = [
[[package]]
name = "rustix"
-version = "0.38.34"
+version = "0.38.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
+checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f"
dependencies = [
"bitflags 2.6.0",
"errno",
@@ -3766,7 +3735,7 @@ dependencies = [
"log",
"once_cell",
"rustls-pki-types",
- "rustls-webpki 0.102.6",
+ "rustls-webpki 0.102.7",
"subtle",
"zeroize",
]
@@ -3785,9 +3754,9 @@ dependencies = [
[[package]]
name = "rustls-native-certs"
-version = "0.7.2"
+version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "04182dffc9091a404e0fc069ea5cd60e5b866c3adf881eff99a32d048242dffa"
+checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5"
dependencies = [
"openssl-probe",
"rustls-pemfile 2.1.3",
@@ -3833,9 +3802,9 @@ dependencies = [
[[package]]
name = "rustls-webpki"
-version = "0.102.6"
+version = "0.102.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e"
+checksum = "84678086bd54edf2b415183ed7a94d0efb049f1b646a33e22a36f3794be6ae56"
dependencies = [
"aws-lc-rs",
"ring",
@@ -4367,27 +4336,17 @@ dependencies = [
"cfg-if",
"fastrand 2.1.1",
"once_cell",
- "rustix 0.38.34",
+ "rustix 0.38.35",
"windows-sys 0.59.0",
]
-[[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 = "terminal_size"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7"
dependencies = [
- "rustix 0.38.34",
+ "rustix 0.38.35",
"windows-sys 0.48.0",
]
@@ -4438,9 +4397,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
-version = "1.39.3"
+version = "1.40.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5"
+checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998"
dependencies = [
"backtrace",
"bytes",
@@ -4921,7 +4880,7 @@ dependencies = [
"either",
"home",
"once_cell",
- "rustix 0.38.34",
+ "rustix 0.38.35",
]
[[package]]
diff --git a/Cargo.toml b/Cargo.toml
index d4878b4..32d309b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,24 +23,24 @@ default = [
"smtp",
"sendmail",
- "wizard",
# "keyring",
# "oauth2",
+ "wizard",
# "pgp-commands",
# "pgp-gpg",
# "pgp-native",
]
-imap = ["email-lib/imap"]
-maildir = ["email-lib/maildir"]
-notmuch = ["email-lib/notmuch"]
-smtp = ["email-lib/smtp"]
-sendmail = ["email-lib/sendmail"]
+imap = ["email-lib/imap", "pimalaya-tui/imap"]
+maildir = ["email-lib/maildir", "pimalaya-tui/maildir"]
+notmuch = ["email-lib/notmuch", "pimalaya-tui/notmuch"]
+smtp = ["email-lib/smtp", "pimalaya-tui/smtp"]
+sendmail = ["email-lib/sendmail", "pimalaya-tui/sendmail"]
-keyring = ["email-lib/keyring", "secret-lib?/keyring-tokio"]
-oauth2 = ["dep:oauth-lib", "email-lib/oauth2", "keyring"]
-wizard = ["dep:secret-lib", "dep:toml_edit", "email-lib/autoconfig"]
+keyring = ["email-lib/keyring", "pimalaya-tui/keyring", "secret-lib?/keyring-tokio"]
+oauth2 = ["dep:oauth-lib", "email-lib/oauth2", "pimalaya-tui/oauth2", "keyring"]
+wizard = ["dep:email_address", "dep:secret-lib", "dep:toml_edit", "email-lib/autoconfig"]
pgp = []
pgp-commands = ["email-lib/pgp-commands", "mml-lib/pgp-commands", "pgp"]
@@ -55,13 +55,11 @@ clap_complete = "4.4"
clap_mangen = "0.2"
color-eyre = "0.6.3"
comfy-table = "7.1.1"
-console = "0.15.2"
crossterm = { version = "0.27", features = ["serde"] }
dirs = "4"
email-lib = { version = "=0.25.0", default-features = false, features = ["derive", "thread", "tracing"] }
-email_address = "0.2.4"
+email_address = { version = "0.2", optional = true }
erased-serde = "0.3"
-indicatif = "0.17"
inquire = "0.7.4"
mail-builder = "0.3"
md5 = "0.7"
@@ -69,6 +67,7 @@ mml-lib = { version = "=1.0.14", default-features = false, features = ["derive"]
oauth-lib = { version = "=0.1.1", optional = true }
once_cell = "1.16"
petgraph = "0.6"
+pimalaya-tui = { version = "=0.1.0", default-features = false, features = ["email", "path"] }
process-lib = { version = "=0.4.2", features = ["derive"] }
secret-lib = { version = "=0.4.6", default-features = false, features = ["command", "derive"], optional = true }
serde = { version = "1", features = ["derive"] }
@@ -76,20 +75,19 @@ serde-toml-merge = "0.3"
serde_json = "1"
shellexpand-utils = "=0.2.1"
sled = "=0.34.7"
-terminal_size = "0.1"
tokio = { version = "1.23", default-features = false, features = ["macros", "rt-multi-thread"] }
toml = "0.8"
toml_edit = { version = "0.22", optional = true }
tracing = "0.1.40"
tracing-error = "0.2.0"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
-unicode-width = "0.1"
url = "2.2"
uuid = { version = "0.8", features = ["v4"] }
[patch.crates-io]
-oauth-lib = { git = "https://github.com/pimalaya/core" }
imap-codec = { git = "https://github.com/duesee/imap-codec" }
imap-next = { git = "https://github.com/duesee/imap-next", branch = "jakoschiko_poison-message-with-fragmentizer" }
imap-client = { git = "https://github.com/pimalaya/imap-client" }
+oauth-lib = { git = "https://github.com/pimalaya/core" }
email-lib = { git = "https://github.com/pimalaya/core" }
+pimalaya-tui = { git = "https://github.com/pimalaya/tui" }
diff --git a/src/account/command/configure.rs b/src/account/command/configure.rs
index 6a3fb0a..4e18780 100644
--- a/src/account/command/configure.rs
+++ b/src/account/command/configure.rs
@@ -4,12 +4,12 @@ use color_eyre::Result;
use email::imap::config::ImapAuthConfig;
#[cfg(feature = "smtp")]
use email::smtp::config::SmtpAuthConfig;
+#[cfg(any(feature = "imap", feature = "smtp", feature = "pgp"))]
+use pimalaya_tui::prompt;
use tracing::info;
#[cfg(any(feature = "imap", feature = "smtp"))]
use tracing::{debug, warn};
-#[cfg(any(feature = "imap", feature = "smtp", feature = "pgp"))]
-use crate::ui::prompt;
use crate::{account::arg::name::AccountNameArg, config::TomlConfig, printer::Printer};
/// Configure an account.
@@ -74,12 +74,14 @@ impl AccountConfigureCommand {
if let Some(ref config) = account_config.imap {
match &config.auth {
ImapAuthConfig::Passwd(config) => {
- config.configure(|| prompt::passwd("IMAP password")).await
+ config
+ .configure(|| Ok(prompt::password("IMAP password")?))
+ .await
}
#[cfg(feature = "oauth2")]
ImapAuthConfig::OAuth2(config) => {
config
- .configure(|| prompt::secret("IMAP OAuth 2.0 client secret"))
+ .configure(|| Ok(prompt::secret("IMAP OAuth 2.0 clientsecret")?))
.await
}
}?;
@@ -89,12 +91,14 @@ impl AccountConfigureCommand {
if let Some(ref config) = account_config.smtp {
match &config.auth {
SmtpAuthConfig::Passwd(config) => {
- config.configure(|| prompt::passwd("SMTP password")).await
+ config
+ .configure(|| Ok(prompt::password("SMTP password")?))
+ .await
}
#[cfg(feature = "oauth2")]
SmtpAuthConfig::OAuth2(config) => {
config
- .configure(|| prompt::secret("SMTP OAuth 2.0 client secret"))
+ .configure(|| Ok(prompt::secret("SMTP OAuth 2.0 client secret")?))
.await
}
}?;
@@ -104,7 +108,7 @@ impl AccountConfigureCommand {
if let Some(ref config) = account_config.pgp {
config
.configure(&account_config.email, || {
- prompt::passwd("PGP secret key password")
+ Ok(prompt::password("PGP secret key password")?)
})
.await?;
}
diff --git a/src/account/wizard.rs b/src/account/wizard.rs
index 1562643..d1b3112 100644
--- a/src/account/wizard.rs
+++ b/src/account/wizard.rs
@@ -1,9 +1,6 @@
-use color_eyre::{eyre::OptionExt, Result};
-use email_address::EmailAddress;
-use inquire::validator::{ErrorMessage, Validation};
-use std::{path::PathBuf, str::FromStr};
+use color_eyre::Result;
+use pimalaya_tui::{print, prompt};
-use crate::wizard_warn;
use crate::{
backend::{self, config::BackendConfig, BackendKind},
message::config::{MessageConfig, MessageSendConfig},
@@ -11,104 +8,66 @@ use crate::{
use super::TomlAccountConfig;
-pub(crate) async fn configure() -> Result