From b0d7e773dc0c5217b27739839c7f2cb730e4bed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20DOUIN?= Date: Tue, 9 Jan 2024 09:28:45 +0100 Subject: [PATCH] renamed sync feature to account-sync, put wizard stuff under feature --- CHANGELOG.md | 4 +- Cargo.lock | 990 ++++++++++++++++-- Cargo.toml | 25 +- flake.nix | 3 + src/account/command/configure.rs | 10 +- src/account/command/mod.rs | 8 +- src/account/config.rs | 4 +- src/account/mod.rs | 1 + src/account/wizard.rs | 16 +- src/backend/mod.rs | 51 +- src/backend/wizard.rs | 2 +- src/config/mod.rs | 27 +- src/config/wizard.rs | 28 +- src/email/envelope/command/list.rs | 10 +- src/email/envelope/command/watch.rs | 8 +- src/email/envelope/flag/command/add.rs | 8 +- src/email/envelope/flag/command/remove.rs | 8 +- src/email/envelope/flag/command/set.rs | 8 +- .../message/attachment/command/download.rs | 8 +- src/email/message/command/copy.rs | 8 +- src/email/message/command/delete.rs | 8 +- src/email/message/command/forward.rs | 8 +- src/email/message/command/mailto.rs | 10 +- src/email/message/command/move_.rs | 8 +- src/email/message/command/read.rs | 8 +- src/email/message/command/reply.rs | 8 +- src/email/message/command/save.rs | 8 +- src/email/message/command/send.rs | 8 +- src/email/message/command/write.rs | 8 +- src/email/message/template/command/forward.rs | 8 +- src/email/message/template/command/reply.rs | 8 +- src/email/message/template/command/save.rs | 8 +- src/email/message/template/command/send.rs | 8 +- src/email/message/template/command/write.rs | 6 +- src/folder/command/create.rs | 10 +- src/folder/command/delete.rs | 10 +- src/folder/command/expunge.rs | 10 +- src/folder/command/list.rs | 10 +- src/folder/command/purge.rs | 10 +- src/imap/args.rs | 62 -- src/imap/handlers.rs | 15 - src/imap/mod.rs | 3 +- src/imap/wizard.rs | 6 +- src/maildir/mod.rs | 1 + src/maildir/wizard.rs | 2 +- src/notmuch/mod.rs | 1 + src/sendmail/mod.rs | 1 + src/sendmail/wizard.rs | 2 +- src/smtp/mod.rs | 1 + src/smtp/wizard.rs | 6 +- src/ui/mod.rs | 6 + src/ui/prompt.rs | 23 + 52 files changed, 1160 insertions(+), 358 deletions(-) delete mode 100644 src/imap/args.rs delete mode 100644 src/imap/handlers.rs create mode 100644 src/ui/prompt.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 73c92dc..5fe89b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,9 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Added cargo feature `sync`. +- Added cargo feature `wizard`, enabled by default. - Added one cargo feature per backend feature: - - `account` including `account-configure`, `account-list`, `sync` and the `account` subcommand + - `account` including `account-configure`, `account-list`, `account-sync` and the `account` subcommand - `folder` including `folder-add`, `folder-list`, `folder-expunge`, `folder-purge`, `folder-delete` and the `folder` subcommand - `envelope` including `envelope-list`, `envelope-watch`, `envelope-get` and the `envelope` subcommand - `flag` including `flag-add`, `flag-set`, `flag-remove` and the `flag` subcommand diff --git a/Cargo.lock b/Cargo.lock index f7bf905..f7b8faa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,6 +33,26 @@ dependencies = [ "winapi", ] +[[package]] +name = "aead" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" +dependencies = [ + "generic-array", +] + +[[package]] +name = "aes" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" +dependencies = [ + "aes-soft", + "aesni", + "cipher 0.2.5", +] + [[package]] name = "aes" version = "0.7.5" @@ -56,6 +76,40 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "aes-gcm" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5278b5fabbb9bd46e24aa69b2fdea62c99088e0a950a9be40e3e0101298f88da" +dependencies = [ + "aead", + "aes 0.6.0", + "cipher 0.2.5", + "ctr", + "ghash", + "subtle", +] + +[[package]] +name = "aes-soft" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" +dependencies = [ + "cipher 0.2.5", + "opaque-debug", +] + +[[package]] +name = "aesni" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" +dependencies = [ + "cipher 0.2.5", + "opaque-debug", +] + [[package]] name = "ahash" version = "0.8.6" @@ -63,7 +117,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", - "getrandom", + "getrandom 0.2.11", "once_cell", "version_check", "zerocopy", @@ -169,6 +223,17 @@ dependencies = [ "futures-core", ] +[[package]] +name = "async-channel" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" +dependencies = [ + "concurrent-queue", + "event-listener 2.5.3", + "futures-core", +] + [[package]] name = "async-channel" version = "2.1.1" @@ -208,6 +273,21 @@ dependencies = [ "futures-lite 1.13.0", ] +[[package]] +name = "async-global-executor" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" +dependencies = [ + "async-channel 2.1.1", + "async-executor", + "async-io 2.2.2", + "async-lock 3.2.0", + "blocking", + "futures-lite 2.1.0", + "once_cell", +] + [[package]] name = "async-io" version = "1.13.0" @@ -313,6 +393,32 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "async-std" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" +dependencies = [ + "async-channel 1.9.0", + "async-global-executor", + "async-io 1.13.0", + "async-lock 2.8.0", + "crossbeam-utils", + "futures-channel", + "futures-core", + "futures-io", + "futures-lite 1.13.0", + "gloo-timers", + "kv-log-macro", + "log", + "memchr", + "once_cell", + "pin-project-lite", + "pin-utils", + "slab", + "wasm-bindgen-futures", +] + [[package]] name = "async-task" version = "4.6.0" @@ -353,6 +459,22 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "autoconfig" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3dc5ca11ac66da7ba331bd707c8d6bca90a559c107aada6ee6abf1d4d5dbc2c" +dependencies = [ + "bytes 1.5.0", + "futures", + "regex", + "serde", + "serde-xml-rs", + "surf", + "trust-dns-proto", + "trust-dns-resolver", +] + [[package]] name = "backtrace" version = "0.3.69" @@ -368,6 +490,12 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base-x" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" + [[package]] name = "base16ct" version = "0.2.0" @@ -416,6 +544,15 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + [[package]] name = "block-buffer" version = "0.10.4" @@ -456,7 +593,7 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ - "async-channel", + "async-channel 2.1.1", "async-lock 3.2.0", "async-task", "fastrand 2.0.1", @@ -527,6 +664,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "bytes" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" + [[package]] name = "bytes" version = "1.5.0" @@ -636,6 +779,15 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "cipher" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" +dependencies = [ + "generic-array", +] + [[package]] name = "cipher" version = "0.3.0" @@ -748,6 +900,12 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "const_fn" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935" + [[package]] name = "constant_time_eq" version = "0.1.5" @@ -769,6 +927,23 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb4a24b1aaf0fd0ce8b45161144d6f42cd91677fd5940fd431183eb023b3a2b8" +[[package]] +name = "cookie" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03a5d7b21829bc7b4bf4754a978a241ae54ea55a40f92bb20216e54096f4b951" +dependencies = [ + "aes-gcm", + "base64 0.13.1", + "hkdf 0.10.0", + "hmac 0.10.1", + "percent-encoding", + "rand 0.8.5", + "sha2 0.9.9", + "time 0.2.27", + "version_check", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -803,6 +978,12 @@ dependencies = [ "libc", ] +[[package]] +name = "cpuid-bool" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba" + [[package]] name = "crc24" version = "0.1.6" @@ -857,7 +1038,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", - "rand_core", + "rand_core 0.6.4", "subtle", "zeroize", ] @@ -872,6 +1053,16 @@ dependencies = [ "typenum", ] +[[package]] +name = "crypto-mac" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4857fd85a0c34b3c3297875b747c1e02e06b6a0ea32dd892d8192b9ce0813ea6" +dependencies = [ + "generic-array", + "subtle", +] + [[package]] name = "cstr-argument" version = "0.1.2" @@ -882,6 +1073,46 @@ dependencies = [ "memchr", ] +[[package]] +name = "ctr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb4a30d54f7443bf3d6191dcd486aca19e67cb3c49fa7a06a319966346707e7f" +dependencies = [ + "cipher 0.2.5", +] + +[[package]] +name = "curl" +version = "0.4.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "509bd11746c7ac09ebd19f0b17782eae80aadee26237658a6b4808afb5c11a22" +dependencies = [ + "curl-sys", + "libc", + "openssl-probe", + "openssl-sys", + "schannel", + "socket2 0.4.10", + "winapi", +] + +[[package]] +name = "curl-sys" +version = "0.4.70+curl-8.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c0333d8849afe78a4c8102a429a446bfdd055832af071945520e835ae2d841e" +dependencies = [ + "cc", + "libc", + "libnghttp2-sys", + "libz-sys", + "openssl-sys", + "pkg-config", + "vcpkg", + "windows-sys 0.48.0", +] + [[package]] name = "curve25519-dalek" version = "4.1.1" @@ -891,10 +1122,10 @@ dependencies = [ "cfg-if", "cpufeatures", "curve25519-dalek-derive", - "digest", + "digest 0.10.7", "fiat-crypto", "platforms", - "rustc_version", + "rustc_version 0.4.0", "subtle", "zeroize", ] @@ -1075,13 +1306,22 @@ dependencies = [ "zeroize", ] +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + [[package]] name = "digest" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer", + "block-buffer 0.10.4", "const-oid", "crypto-common", "subtle", @@ -1149,6 +1389,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "discard" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" + [[package]] name = "ecdsa" version = "0.16.9" @@ -1156,7 +1402,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der", - "digest", + "digest 0.10.7", "elliptic-curve", "rfc6979", "signature", @@ -1182,7 +1428,7 @@ dependencies = [ "curve25519-dalek", "ed25519", "serde", - "sha2", + "sha2 0.10.8", "subtle", "zeroize", ] @@ -1201,14 +1447,14 @@ checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", "crypto-bigint", - "digest", + "digest 0.10.7", "ff", "generic-array", "group", - "hkdf", + "hkdf 0.12.4", "pem-rfc7468", "pkcs8", - "rand_core", + "rand_core 0.6.4", "sec1", "subtle", "zeroize", @@ -1282,6 +1528,18 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "enum-as-inner" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "enum-as-inner" version = "0.6.0" @@ -1424,7 +1682,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ - "rand_core", + "rand_core 0.6.4", "subtle", ] @@ -1462,6 +1720,17 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "flume" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bebadab126f8120d410b677ed95eee4ba6eb7c6dd8e34a5ec88a08050e26132" +dependencies = [ + "futures-core", + "futures-sink", + "spinning_top", +] + [[package]] name = "fnv" version = "1.0.7" @@ -1636,6 +1905,17 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + [[package]] name = "getrandom" version = "0.2.11" @@ -1645,16 +1925,38 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "wasm-bindgen", ] +[[package]] +name = "ghash" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97304e4cd182c3846f7575ced3890c53012ce534ad9114046b0a9e00bb30a375" +dependencies = [ + "opaque-debug", + "polyval", +] + [[package]] name = "gimli" version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +[[package]] +name = "gloo-timers" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + [[package]] name = "gpg-error" version = "0.6.0" @@ -1703,7 +2005,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", - "rand_core", + "rand_core 0.6.4", "subtle", ] @@ -1713,7 +2015,7 @@ version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" dependencies = [ - "bytes", + "bytes 1.5.0", "fnv", "futures-core", "futures-sink", @@ -1781,14 +2083,14 @@ dependencies = [ "async-trait", "cfg-if", "data-encoding", - "enum-as-inner", + "enum-as-inner 0.6.0", "futures-channel", "futures-io", "futures-util", "idna 0.4.0", "ipnet", "once_cell", - "rand", + "rand 0.8.5", "ring 0.16.20", "rustls 0.21.10", "rustls-pemfile", @@ -1813,7 +2115,7 @@ dependencies = [ "lru-cache", "once_cell", "parking_lot", - "rand", + "rand 0.8.5", "resolv-conf", "rustls 0.21.10", "smallvec", @@ -1829,6 +2131,7 @@ version = "1.0.0-beta.2" dependencies = [ "anyhow", "async-trait", + "autoconfig", "chrono", "clap", "clap_complete", @@ -1866,13 +2169,33 @@ dependencies = [ "uuid", ] +[[package]] +name = "hkdf" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51ab2f639c231793c5f6114bdb9bbe50a7dbbfcd7c7c6bd8475dec2d991e964f" +dependencies = [ + "digest 0.9.0", + "hmac 0.10.1", +] + [[package]] name = "hkdf" version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" dependencies = [ - "hmac", + "hmac 0.12.1", +] + +[[package]] +name = "hmac" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" +dependencies = [ + "crypto-mac", + "digest 0.9.0", ] [[package]] @@ -1881,7 +2204,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest", + "digest 0.10.7", ] [[package]] @@ -1901,7 +2224,7 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" dependencies = [ - "bytes", + "bytes 1.5.0", "fnv", "itoa", ] @@ -1912,11 +2235,47 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ - "bytes", + "bytes 1.5.0", "http", "pin-project-lite", ] +[[package]] +name = "http-client" +version = "6.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1947510dc91e2bf586ea5ffb412caad7673264e14bb39fb9078da114a94ce1a5" +dependencies = [ + "async-std", + "async-trait", + "cfg-if", + "http-types", + "isahc", + "log", +] + +[[package]] +name = "http-types" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e9b187a72d63adbfba487f48095306ac823049cb504ee195541e91c7775f5ad" +dependencies = [ + "anyhow", + "async-channel 1.9.0", + "async-std", + "base64 0.13.1", + "cookie", + "futures-lite 1.13.0", + "infer", + "pin-project-lite", + "rand 0.7.3", + "serde", + "serde_json", + "serde_qs", + "serde_urlencoded", + "url", +] + [[package]] name = "httparse" version = "1.8.0" @@ -1941,7 +2300,7 @@ version = "0.14.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" dependencies = [ - "bytes", + "bytes 1.5.0", "futures-channel", "futures-core", "futures-util", @@ -2013,6 +2372,17 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "idna" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "idna" version = "0.4.0" @@ -2082,6 +2452,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "infer" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64e9829a50b42bb782c1df523f78d332fe371b10c661e78b7a3c34b0198e9fac" + [[package]] name = "inotify" version = "0.9.6" @@ -2149,6 +2525,29 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +[[package]] +name = "isahc" +version = "0.9.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2948a0ce43e2c2ef11d7edf6816508998d99e13badd1150be0914205df9388a" +dependencies = [ + "bytes 0.5.6", + "crossbeam-utils", + "curl", + "curl-sys", + "flume", + "futures-lite 1.13.0", + "http", + "log", + "once_cell", + "slab", + "sluice", + "tracing", + "tracing-futures", + "url", + "waker-fn", +] + [[package]] name = "itoa" version = "1.0.10" @@ -2230,6 +2629,15 @@ dependencies = [ "libc", ] +[[package]] +name = "kv-log-macro" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" +dependencies = [ + "log", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -2262,6 +2670,16 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +[[package]] +name = "libnghttp2-sys" +version = "0.1.9+1.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b57e858af2798e167e709b9d969325b6d8e9d50232fcbc494d7d54f976854a64" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "libredox" version = "0.0.1" @@ -2284,6 +2702,18 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "libz-sys" +version = "1.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f526fdd09d99e19742883e43de41e1aa9e36db0c7ab7f935165d611c5cccc66" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "linked-hash-map" version = "0.5.6" @@ -2327,6 +2757,9 @@ name = "log" version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +dependencies = [ + "value-bag", +] [[package]] name = "lru-cache" @@ -2347,7 +2780,7 @@ dependencies = [ "dirs-next", "objc-foundation", "objc_id", - "time", + "time 0.3.31", ] [[package]] @@ -2400,7 +2833,7 @@ dependencies = [ "mail-auth", "mail-builder", "md5", - "rand", + "rand 0.8.5", "rustls 0.22.1", "rustls-pki-types", "smtp-proto", @@ -2435,6 +2868,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" +[[package]] +name = "matches" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" + [[package]] name = "md-5" version = "0.10.6" @@ -2442,7 +2881,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" dependencies = [ "cfg-if", - "digest", + "digest 0.10.7", ] [[package]] @@ -2481,6 +2920,16 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "mime_guess" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -2504,7 +2953,7 @@ checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.48.0", ] @@ -2636,7 +3085,7 @@ dependencies = [ "num-integer", "num-iter", "num-traits", - "rand", + "rand 0.8.5", "serde", "smallvec", "zeroize", @@ -2743,14 +3192,14 @@ checksum = "c38841cdd844847e3e7c8d29cef9dcfed8877f8f56f9071f77843ecf3baf937f" dependencies = [ "base64 0.13.1", "chrono", - "getrandom", + "getrandom 0.2.11", "http", - "rand", + "rand 0.8.5", "reqwest", "serde", "serde_json", "serde_path_to_error", - "sha2", + "sha2 0.10.8", "thiserror", "url", ] @@ -2811,6 +3260,18 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-sys" +version = "0.9.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1665caf8ab2dc9aef43d1c0023bd904633a6a05cb30b0ad59bec2ae986e57a7" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "option-ext" version = "0.2.0" @@ -2892,7 +3353,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "primeorder", - "sha2", + "sha2 0.10.8", ] [[package]] @@ -2904,7 +3365,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "primeorder", - "sha2", + "sha2 0.10.8", ] [[package]] @@ -2943,7 +3404,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" dependencies = [ "base64ct", - "rand_core", + "rand_core 0.6.4", "subtle", ] @@ -2953,10 +3414,10 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ - "digest", - "hmac", + "digest 0.10.7", + "hmac 0.12.1", "password-hash", - "sha2", + "sha2 0.10.8", ] [[package]] @@ -3007,7 +3468,7 @@ dependencies = [ "curve25519-dalek", "derive_builder", "des", - "digest", + "digest 0.10.7", "ed25519-dalek", "elliptic-curve", "flate2", @@ -3022,11 +3483,11 @@ dependencies = [ "num-traits", "p256", "p384", - "rand", + "rand 0.8.5", "ripemd", "rsa", - "sha1", - "sha2", + "sha1 0.10.6", + "sha2 0.10.8", "sha3", "signature", "smallvec", @@ -3048,8 +3509,8 @@ dependencies = [ "hyper-rustls", "log", "pgp", - "rand", - "sha1", + "rand 0.8.5", + "sha1 0.10.6", "smallvec", "thiserror", "tokio", @@ -3057,6 +3518,26 @@ dependencies = [ "z-base-32", ] +[[package]] +name = "pin-project" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.41", +] + [[package]] name = "pin-project-lite" version = "0.2.13" @@ -3143,6 +3624,17 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "polyval" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd" +dependencies = [ + "cpuid-bool", + "opaque-debug", + "universal-hash", +] + [[package]] name = "portable-atomic" version = "1.6.0" @@ -3204,6 +3696,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "proc-macro-hack" +version = "0.5.20+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" + [[package]] name = "proc-macro2" version = "1.0.70" @@ -3259,6 +3757,19 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + [[package]] name = "rand" version = "0.8.5" @@ -3266,8 +3777,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", ] [[package]] @@ -3277,7 +3798,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", ] [[package]] @@ -3286,7 +3816,16 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.11", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", ] [[package]] @@ -3324,7 +3863,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ - "getrandom", + "getrandom 0.2.11", "libredox", "thiserror", ] @@ -3382,7 +3921,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" dependencies = [ "base64 0.21.5", - "bytes", + "bytes 1.5.0", "encoding_rs", "futures-core", "futures-util", @@ -3431,7 +3970,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ - "hmac", + "hmac 0.12.1", "subtle", ] @@ -3457,7 +3996,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" dependencies = [ "cc", - "getrandom", + "getrandom 0.2.11", "libc", "spin 0.9.8", "untrusted 0.9.0", @@ -3470,7 +4009,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" dependencies = [ - "digest", + "digest 0.10.7", ] [[package]] @@ -3486,13 +4025,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" dependencies = [ "const-oid", - "digest", + "digest 0.10.7", "num-bigint-dig", "num-integer", "num-traits", "pkcs1", "pkcs8", - "rand_core", + "rand_core 0.6.4", "signature", "spki", "subtle", @@ -3519,13 +4058,22 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver 0.9.0", +] + [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver", + "semver 1.0.20", ] [[package]] @@ -3723,12 +4271,12 @@ dependencies = [ "block-modes", "futures-util", "generic-array", - "hkdf", + "hkdf 0.12.4", "num", "once_cell", - "rand", + "rand 0.8.5", "serde", - "sha2", + "sha2 0.10.8", "zbus", ] @@ -3755,12 +4303,27 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + [[package]] name = "semver" version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + [[package]] name = "serde" version = "1.0.193" @@ -3770,6 +4333,18 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-xml-rs" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb3aa78ecda1ebc9ec9847d5d3aba7d618823446a049ba2491940506da6e2782" +dependencies = [ + "log", + "serde", + "thiserror", + "xml-rs", +] + [[package]] name = "serde_derive" version = "1.0.193" @@ -3802,6 +4377,17 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_qs" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7715380eec75f029a4ef7de39a9200e0a63823176b759d055b613f5a87df6a6" +dependencies = [ + "percent-encoding", + "serde", + "thiserror", +] + [[package]] name = "serde_repr" version = "0.1.17" @@ -3834,6 +4420,15 @@ dependencies = [ "serde", ] +[[package]] +name = "sha1" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770" +dependencies = [ + "sha1_smol", +] + [[package]] name = "sha1" version = "0.10.6" @@ -3842,7 +4437,26 @@ checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", "cpufeatures", - "digest", + "digest 0.10.7", +] + +[[package]] +name = "sha1_smol" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", ] [[package]] @@ -3853,7 +4467,7 @@ checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", - "digest", + "digest 0.10.7", ] [[package]] @@ -3862,7 +4476,7 @@ version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ - "digest", + "digest 0.10.7", "keccak", ] @@ -3909,8 +4523,8 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "digest", - "rand_core", + "digest 0.10.7", + "rand_core 0.6.4", ] [[package]] @@ -3922,6 +4536,17 @@ dependencies = [ "autocfg", ] +[[package]] +name = "sluice" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d7400c0eff44aa2fcb5e31a5f24ba9716ed90138769e4977a2ba6014ae63eb5" +dependencies = [ + "async-channel 1.9.0", + "futures-core", + "futures-io", +] + [[package]] name = "smallvec" version = "1.11.2" @@ -3966,6 +4591,15 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "spinning_top" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" +dependencies = [ + "lock_api", +] + [[package]] name = "spki" version = "0.7.3" @@ -3989,12 +4623,70 @@ dependencies = [ "winapi", ] +[[package]] +name = "standback" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" +dependencies = [ + "version_check", +] + [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "stdweb" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" +dependencies = [ + "discard", + "rustc_version 0.2.3", + "stdweb-derive", + "stdweb-internal-macros", + "stdweb-internal-runtime", + "wasm-bindgen", +] + +[[package]] +name = "stdweb-derive" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "serde_derive", + "syn 1.0.109", +] + +[[package]] +name = "stdweb-internal-macros" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" +dependencies = [ + "base-x", + "proc-macro2", + "quote", + "serde", + "serde_derive", + "serde_json", + "sha1 0.6.1", + "syn 1.0.109", +] + +[[package]] +name = "stdweb-internal-runtime" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" + [[package]] name = "strsim" version = "0.9.3" @@ -4013,6 +4705,29 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "surf" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "718b1ae6b50351982dedff021db0def601677f2120938b070eadb10ba4038dd7" +dependencies = [ + "async-std", + "async-trait", + "cfg-if", + "encoding_rs", + "futures-util", + "getrandom 0.2.11", + "http-client", + "http-types", + "log", + "mime_guess", + "once_cell", + "pin-project-lite", + "serde", + "serde_json", + "web-sys", +] + [[package]] name = "syn" version = "1.0.109" @@ -4137,6 +4852,21 @@ dependencies = [ "syn 2.0.41", ] +[[package]] +name = "time" +version = "0.2.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242" +dependencies = [ + "const_fn", + "libc", + "standback", + "stdweb", + "time-macros", + "version_check", + "winapi", +] + [[package]] name = "time" version = "0.3.31" @@ -4155,6 +4885,29 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" +[[package]] +name = "time-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" +dependencies = [ + "proc-macro-hack", + "time-macros-impl", +] + +[[package]] +name = "time-macros-impl" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "standback", + "syn 1.0.109", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -4177,7 +4930,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "841d45b238a16291a4e1584e61820b8ae57d696cc5015c459c229ccc6990cc1c" dependencies = [ "backtrace", - "bytes", + "bytes 1.5.0", "libc", "mio", "num_cpus", @@ -4227,7 +4980,7 @@ version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ - "bytes", + "bytes 1.5.0", "futures-core", "futures-sink", "pin-project-lite", @@ -4306,6 +5059,7 @@ version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ + "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -4331,6 +5085,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project", + "tracing", +] + [[package]] name = "tree_magic_mini" version = "3.0.3" @@ -4345,6 +5109,51 @@ dependencies = [ "petgraph", ] +[[package]] +name = "trust-dns-proto" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f7f83d1e4a0e4358ac54c5c3681e5d7da5efc5a7a632c90bb6d6669ddd9bc26" +dependencies = [ + "async-trait", + "cfg-if", + "data-encoding", + "enum-as-inner 0.5.1", + "futures-channel", + "futures-io", + "futures-util", + "idna 0.2.3", + "ipnet", + "lazy_static", + "rand 0.8.5", + "smallvec", + "thiserror", + "tinyvec", + "tokio", + "tracing", + "url", +] + +[[package]] +name = "trust-dns-resolver" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aff21aa4dcefb0a1afbfac26deb0adc93888c7d295fb63ab273ef276ba2b7cfe" +dependencies = [ + "cfg-if", + "futures-util", + "ipconfig", + "lazy_static", + "lru-cache", + "parking_lot", + "resolv-conf", + "smallvec", + "thiserror", + "tokio", + "tracing", + "trust-dns-proto", +] + [[package]] name = "try-lock" version = "0.2.5" @@ -4377,6 +5186,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-bidi" version = "0.3.14" @@ -4404,6 +5222,16 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +[[package]] +name = "universal-hash" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" +dependencies = [ + "generic-array", + "subtle", +] + [[package]] name = "untrusted" version = "0.7.1" @@ -4457,9 +5285,15 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "getrandom", + "getrandom 0.2.11", ] +[[package]] +name = "value-bag" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cdbaf5e132e593e9fc1de6a15bbec912395b11fb9719e061cf64f804524c503" + [[package]] name = "vcpkg" version = "0.2.15" @@ -4503,6 +5337,12 @@ dependencies = [ "try-lock", ] +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -4889,7 +5729,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb66477291e7e8d2b0ff1bcb900bf29489a9692816d79874bea351e7a8b6de96" dependencies = [ "curve25519-dalek", - "rand_core", + "rand_core 0.6.4", "serde", "zeroize", ] @@ -4904,6 +5744,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "xml-rs" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a" + [[package]] name = "z-base-32" version = "0.1.3" @@ -4937,10 +5783,10 @@ dependencies = [ "nix", "once_cell", "ordered-stream", - "rand", + "rand 0.8.5", "serde", "serde_repr", - "sha1", + "sha1 0.10.6", "static_assertions", "tokio", "tracing", @@ -5030,10 +5876,10 @@ dependencies = [ "crc32fast", "crossbeam-utils", "flate2", - "hmac", + "hmac 0.12.1", "pbkdf2", - "sha1", - "time", + "sha1 0.10.6", + "time 0.3.31", "zstd", ] diff --git a/Cargo.toml b/Cargo.toml index 8b7e9a9..d0f7a77 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,8 +6,8 @@ authors = ["soywod "] edition = "2021" license = "MIT" categories = ["command-line-interface", "command-line-utilities", "email"] -keywords = ["cli", "mail", "email", "client", "imap"] -homepage = "https://pimalaya.org/himalaya/cli/latest/" +keywords = ["cli", "email", "imap", "smtp", "sync"] +homepage = "https://pimalaya.org/" documentation = "https://pimalaya.org/himalaya/cli/latest/" repository = "https://github.com/soywod/himalaya/" @@ -16,12 +16,17 @@ all-features = true rustdoc-args = ["--cfg", "docsrs"] [features] +# features documentation: +# https://pimalaya.org/himalaya/cli/latest/installation.html#cargo default = [ + "wizard", + "imap", "maildir", # "notmuch", "smtp", "sendmail", + "account", "folder", "envelope", @@ -29,21 +34,25 @@ default = [ "message", "attachment", "template", - "sync", - # "pgp-commands", - # "pgp-gpg", + + # "pgp-commands", # enable PGP based on shell commands + # "pgp-gpg", # enable # "pgp-native", ] + +wizard = ["autoconfig"] + imap = ["email-lib/imap"] maildir = ["email-lib/maildir"] notmuch = ["email-lib/notmuch"] smtp = ["email-lib/smtp"] sendmail = ["email-lib/sendmail"] -account = ["account-configure", "account-list", "sync"] + +account = ["account-configure", "account-list", "account-sync"] account-subcmd = [] account-configure = ["account-subcmd"] account-list = ["account-subcmd"] -sync = ["account-subcmd", "email-lib/sync"] +account-sync = ["account-subcmd", "email-lib/sync"] folder = ["folder-add", "folder-list", "folder-expunge", "folder-purge", "folder-delete"] folder-subcmd = [] folder-add = ["folder-subcmd", "email-lib/folder-add"] @@ -86,6 +95,7 @@ template-reply = ["template-subcmd", "email-lib/message-get"] template-forward = ["template-subcmd", "email-lib/message-get"] template-save = ["template-subcmd", "email-lib/message-add"] template-send = ["template-subcmd", "email-lib/message-send"] + pgp = [] pgp-commands = ["email-lib/pgp-commands", "mml-lib/pgp-commands", "pgp"] pgp-gpg = ["email-lib/pgp-gpg", "mml-lib/pgp-gpg", "pgp"] @@ -98,6 +108,7 @@ tempfile = "3.3" [dependencies] anyhow = "1" async-trait = "0.1" +autoconfig = { version = "0.4", optional = true } chrono = "0.4.24" clap = { version = "4.4", features = ["derive"] } clap_complete = "4.4" diff --git a/flake.nix b/flake.nix index feb0a78..7030070 100644 --- a/flake.nix +++ b/flake.nix @@ -46,6 +46,9 @@ # Rust rust-toolchain + # OpenSSL + openssl.dev + # Notmuch notmuch diff --git a/src/account/command/configure.rs b/src/account/command/configure.rs index cd272cf..a070706 100644 --- a/src/account/command/configure.rs +++ b/src/account/command/configure.rs @@ -9,7 +9,7 @@ use log::info; use log::{debug, warn}; #[cfg(any(feature = "imap", feature = "smtp"))] -use crate::config::wizard::{prompt_passwd, prompt_secret}; +use crate::ui::prompt; use crate::{account::arg::name::AccountNameArg, config::TomlConfig, printer::Printer}; /// Configure an account. @@ -72,11 +72,11 @@ 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(|| prompt::passwd("IMAP password")).await } ImapAuthConfig::OAuth2(config) => { config - .configure(|| prompt_secret("IMAP OAuth 2.0 client secret")) + .configure(|| prompt::secret("IMAP OAuth 2.0 client secret")) .await } }?; @@ -86,11 +86,11 @@ 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(|| prompt::passwd("SMTP password")).await } SmtpAuthConfig::OAuth2(config) => { config - .configure(|| prompt_secret("SMTP OAuth 2.0 client secret")) + .configure(|| prompt::secret("SMTP OAuth 2.0 client secret")) .await } }?; diff --git a/src/account/command/mod.rs b/src/account/command/mod.rs index f01c491..cdac4f8 100644 --- a/src/account/command/mod.rs +++ b/src/account/command/mod.rs @@ -2,7 +2,7 @@ mod configure; #[cfg(feature = "account-list")] mod list; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] mod sync; use anyhow::Result; @@ -14,7 +14,7 @@ use crate::{config::TomlConfig, printer::Printer}; use self::configure::AccountConfigureCommand; #[cfg(feature = "account-list")] use self::list::AccountListCommand; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use self::sync::AccountSyncCommand; /// Manage accounts. @@ -32,7 +32,7 @@ pub enum AccountSubcommand { #[command(alias = "lst")] List(AccountListCommand), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(alias = "synchronize", alias = "synchronise")] Sync(AccountSyncCommand), } @@ -45,7 +45,7 @@ impl AccountSubcommand { Self::Configure(cmd) => cmd.execute(printer, config).await, #[cfg(feature = "account-list")] Self::List(cmd) => cmd.execute(printer, config).await, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Self::Sync(cmd) => cmd.execute(printer, config).await, } } diff --git a/src/account/config.rs b/src/account/config.rs index 217cc1e..65e9e4f 100644 --- a/src/account/config.rs +++ b/src/account/config.rs @@ -5,7 +5,7 @@ #[cfg(feature = "pgp")] use email::account::config::pgp::PgpConfig; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use email::account::sync::config::SyncConfig; #[cfg(feature = "imap")] use email::imap::config::ImapConfig; @@ -35,7 +35,7 @@ pub struct TomlAccountConfig { pub downloads_dir: Option, pub backend: Option, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] pub sync: Option, #[cfg(feature = "pgp")] pub pgp: Option, diff --git a/src/account/mod.rs b/src/account/mod.rs index 62bed18..41e1d89 100644 --- a/src/account/mod.rs +++ b/src/account/mod.rs @@ -1,6 +1,7 @@ pub mod arg; pub mod command; pub mod config; +#[cfg(feature = "wizard")] pub(crate) mod wizard; use anyhow::Result; diff --git a/src/account/wizard.rs b/src/account/wizard.rs index 359f86a..d9f5427 100644 --- a/src/account/wizard.rs +++ b/src/account/wizard.rs @@ -1,20 +1,18 @@ use anyhow::{bail, Result}; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use dialoguer::Confirm; use dialoguer::Input; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use email::account::sync::config::SyncConfig; use email_address::EmailAddress; +#[allow(unused)] +use crate::backend::{self, config::BackendConfig, BackendKind}; #[cfg(feature = "message-send")] use crate::message::config::{MessageConfig, MessageSendConfig}; -#[cfg(feature = "sync")] +use crate::ui::THEME; +#[cfg(feature = "account-sync")] use crate::wizard_prompt; -#[allow(unused)] -use crate::{ - backend::{self, config::BackendConfig, BackendKind}, - config::wizard::THEME, -}; use super::TomlAccountConfig; @@ -104,7 +102,7 @@ pub(crate) async fn configure() -> Result> { _ => (), }; - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] { let should_configure_sync = Confirm::new() .with_prompt(wizard_prompt!( diff --git a/src/backend/mod.rs b/src/backend/mod.rs index df069c0..6acf7d8 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -1,4 +1,5 @@ pub mod config; +#[cfg(feature = "wizard")] pub(crate) mod wizard; use anyhow::Result; @@ -52,7 +53,7 @@ use email::folder::list::maildir::ListFoldersMaildir; use email::folder::purge::imap::PurgeFolderImap; #[cfg(feature = "imap")] use email::imap::{ImapSessionBuilder, ImapSessionSync}; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use email::maildir::config::MaildirConfig; #[cfg(feature = "maildir")] use email::maildir::{MaildirSessionBuilder, MaildirSessionSync}; @@ -99,7 +100,7 @@ pub enum BackendKind { Imap, #[cfg(feature = "maildir")] Maildir, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[serde(skip_deserializing)] MaildirForSync, #[cfg(feature = "notmuch")] @@ -118,7 +119,7 @@ impl ToString for BackendKind { Self::Imap => "IMAP", #[cfg(feature = "maildir")] Self::Maildir => "Maildir", - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Self::MaildirForSync => "Maildir", #[cfg(feature = "notmuch")] Self::Notmuch => "Notmuch", @@ -139,7 +140,7 @@ pub struct BackendContextBuilder { pub imap: Option, #[cfg(feature = "maildir")] pub maildir: Option, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] pub maildir_for_sync: Option, #[cfg(feature = "smtp")] pub smtp: Option, @@ -178,7 +179,7 @@ impl BackendContextBuilder { .map(|mdir_config| { MaildirSessionBuilder::new(account_config.clone(), mdir_config.clone()) }), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] maildir_for_sync: Some(MaildirConfig { root_dir: account_config.get_sync_dir()?, }) @@ -230,7 +231,7 @@ impl email::backend::BackendContextBuilder for BackendContextBuilder { ctx.maildir = Some(maildir.build().await?); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] if let Some(maildir) = self.maildir_for_sync { ctx.maildir_for_sync = Some(maildir.build().await?); } @@ -260,7 +261,7 @@ pub struct BackendContext { pub imap: Option, #[cfg(feature = "maildir")] pub maildir: Option, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] pub maildir_for_sync: Option, #[cfg(feature = "smtp")] pub smtp: Option, @@ -285,7 +286,7 @@ impl BackendBuilder { let is_imap_used = used_backends.contains(&BackendKind::Imap); #[cfg(feature = "maildir")] let is_maildir_used = used_backends.contains(&BackendKind::Maildir); - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] let is_maildir_for_sync_used = used_backends.contains(&BackendKind::MaildirForSync); let backend_ctx_builder = BackendContextBuilder { @@ -313,7 +314,7 @@ impl BackendBuilder { .map(|mdir_config| { MaildirSessionBuilder::new(account_config.clone(), mdir_config.clone()) }), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] maildir_for_sync: Some(MaildirConfig { root_dir: account_config.get_sync_dir()?, }) @@ -333,7 +334,7 @@ impl BackendBuilder { backend_builder = backend_builder .with_add_folder(|ctx| ctx.maildir.as_ref().and_then(AddFolderMaildir::new)); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { backend_builder = backend_builder.with_add_folder(|ctx| { ctx.maildir_for_sync @@ -362,7 +363,7 @@ impl BackendBuilder { ctx.maildir.as_ref().and_then(ListFoldersMaildir::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { backend_builder = backend_builder.with_list_folders(|ctx| { ctx.maildir_for_sync @@ -392,7 +393,7 @@ impl BackendBuilder { ctx.maildir.as_ref().and_then(ExpungeFolderMaildir::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { backend_builder = backend_builder.with_expunge_folder(|ctx| { ctx.maildir_for_sync @@ -423,7 +424,7 @@ impl BackendBuilder { // .with_purge_folder(|ctx| ctx.maildir.as_ref().and_then(PurgeFolderMaildir::new)); // } // TODO - // #[cfg(feature = "sync")] + // #[cfg(feature = "account-sync")] // Some(BackendKind::MaildirForSync) => { // backend_builder = backend_builder // .with_purge_folder(|ctx| ctx.maildir_for_sync.as_ref().and_then(PurgeFolderMaildir::new)); @@ -450,7 +451,7 @@ impl BackendBuilder { ctx.maildir.as_ref().and_then(DeleteFolderMaildir::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { backend_builder = backend_builder.with_delete_folder(|ctx| { ctx.maildir_for_sync @@ -480,7 +481,7 @@ impl BackendBuilder { ctx.maildir.as_ref().and_then(ListEnvelopesMaildir::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { backend_builder = backend_builder.with_list_envelopes(|ctx| { ctx.maildir_for_sync @@ -510,7 +511,7 @@ impl BackendBuilder { ctx.maildir.as_ref().and_then(WatchMaildirEnvelopes::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { backend_builder = backend_builder.with_watch_envelopes(|ctx| { ctx.maildir_for_sync @@ -541,7 +542,7 @@ impl BackendBuilder { ctx.maildir.as_ref().and_then(GetEnvelopeMaildir::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { backend_builder = backend_builder.with_get_envelope(|ctx| { ctx.maildir_for_sync @@ -570,7 +571,7 @@ impl BackendBuilder { backend_builder = backend_builder .with_add_flags(|ctx| ctx.maildir.as_ref().and_then(AddFlagsMaildir::new)); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { backend_builder = backend_builder.with_add_flags(|ctx| { ctx.maildir_for_sync.as_ref().and_then(AddFlagsMaildir::new) @@ -596,7 +597,7 @@ impl BackendBuilder { backend_builder = backend_builder .with_set_flags(|ctx| ctx.maildir.as_ref().and_then(SetFlagsMaildir::new)); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { backend_builder = backend_builder.with_set_flags(|ctx| { ctx.maildir_for_sync.as_ref().and_then(SetFlagsMaildir::new) @@ -623,7 +624,7 @@ impl BackendBuilder { ctx.maildir.as_ref().and_then(RemoveFlagsMaildir::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { backend_builder = backend_builder.with_remove_flags(|ctx| { ctx.maildir_for_sync @@ -658,7 +659,7 @@ impl BackendBuilder { backend_builder = backend_builder .with_add_message(|ctx| ctx.maildir.as_ref().and_then(AddMaildirMessage::new)); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { backend_builder = backend_builder.with_add_message(|ctx| { ctx.maildir_for_sync @@ -683,7 +684,7 @@ impl BackendBuilder { ctx.maildir.as_ref().and_then(PeekMessagesMaildir::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { backend_builder = backend_builder.with_peek_messages(|ctx| { ctx.maildir_for_sync @@ -729,7 +730,7 @@ impl BackendBuilder { ctx.maildir.as_ref().and_then(CopyMessagesMaildir::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { backend_builder = backend_builder.with_copy_messages(|ctx| { ctx.maildir_for_sync @@ -759,7 +760,7 @@ impl BackendBuilder { ctx.maildir.as_ref().and_then(MoveMessagesMaildir::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { backend_builder = backend_builder.with_move_messages(|ctx| { ctx.maildir_for_sync @@ -856,7 +857,7 @@ impl Backend { )?; } } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { id_mapper = IdMapper::new( &self.backend.account_config, diff --git a/src/backend/wizard.rs b/src/backend/wizard.rs index 58fcd90..d75283b 100644 --- a/src/backend/wizard.rs +++ b/src/backend/wizard.rs @@ -1,7 +1,6 @@ use anyhow::Result; use dialoguer::Select; -use crate::config::wizard::THEME; #[cfg(feature = "imap")] use crate::imap; #[cfg(feature = "maildir")] @@ -12,6 +11,7 @@ use crate::notmuch; use crate::sendmail; #[cfg(feature = "smtp")] use crate::smtp; +use crate::ui::THEME; use super::{config::BackendConfig, BackendKind}; diff --git a/src/config/mod.rs b/src/config/mod.rs index 26c28ba..413a470 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1,8 +1,8 @@ pub mod args; +#[cfg(feature = "wizard")] pub mod wizard; use anyhow::{anyhow, Context, Result}; -use dialoguer::Confirm; use dirs::{config_dir, home_dir}; use email::{ account::config::AccountConfig, config::Config, envelope::config::EnvelopeConfig, @@ -15,13 +15,14 @@ use std::{ collections::HashMap, fs, path::{Path, PathBuf}, - process, }; use toml; -#[cfg(feature = "sync")] +use crate::account::config::TomlAccountConfig; +#[cfg(feature = "account-sync")] use crate::backend::BackendKind; -use crate::{account::config::TomlAccountConfig, wizard_prompt, wizard_warn}; +#[cfg(feature = "wizard")] +use crate::{wizard_prompt, wizard_warn}; /// Represents the user config file. #[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize)] @@ -48,6 +49,7 @@ impl TomlConfig { toml::from_str(&content).context(format!("cannot parse config file at {path:?}")) } + #[cfg(feature = "wizard")] /// Create and save a TOML configuration using the wizard. /// /// If the user accepts the confirmation, the wizard starts and @@ -56,6 +58,9 @@ impl TomlConfig { /// /// NOTE: the wizard can only be used with interactive shells. async fn from_wizard(path: PathBuf) -> Result { + use dialoguer::Confirm; + use std::process; + wizard_warn!("Cannot find existing configuration at {path:?}."); let confirm = Confirm::new() @@ -77,7 +82,10 @@ impl TomlConfig { pub async fn from_default_paths() -> Result { match Self::first_valid_default_path() { Some(path) => Self::from_path(&path), + #[cfg(feature = "wizard")] None => Self::from_wizard(Self::default_path()?).await, + #[cfg(not(feature = "wizard"))] + None => anyhow::bail!("cannot find configuration file from default locations"), } } @@ -96,8 +104,9 @@ impl TomlConfig { pub async fn from_some_path_or_default(path: Option>) -> Result { match path.map(Into::into) { Some(ref path) if path.exists() => Self::from_path(path), + #[cfg(feature = "wizard")] Some(path) => Self::from_wizard(path).await, - None => Self::from_default_paths().await, + _ => Self::from_default_paths().await, } } @@ -175,13 +184,13 @@ impl TomlConfig { pub fn into_account_configs( self, account_name: Option<&str>, - #[cfg(feature = "sync")] disable_cache: bool, + #[cfg(feature = "account-sync")] disable_cache: bool, ) -> Result<(TomlAccountConfig, AccountConfig)> { - #[cfg_attr(not(feature = "sync"), allow(unused_mut))] + #[cfg_attr(not(feature = "account-sync"), allow(unused_mut))] let (account_name, mut toml_account_config) = self.into_toml_account_config(account_name)?; - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] if let Some(true) = toml_account_config.sync.as_ref().and_then(|c| c.enable) { if !disable_cache { toml_account_config.backend = Some(BackendKind::MaildirForSync); @@ -228,7 +237,7 @@ impl TomlConfig { send: c.send.map(|c| c.remote), ..Default::default() }), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] sync: config.sync, #[cfg(feature = "pgp")] pgp: config.pgp, diff --git a/src/config/wizard.rs b/src/config/wizard.rs index 866e71c..3e03d19 100644 --- a/src/config/wizard.rs +++ b/src/config/wizard.rs @@ -1,11 +1,10 @@ use anyhow::Result; -use dialoguer::{theme::ColorfulTheme, Confirm, Input, Password, Select}; -use once_cell::sync::Lazy; +use dialoguer::{Confirm, Input, Select}; use shellexpand_utils::expand; -use std::{fs, io, path::PathBuf, process}; +use std::{fs, path::PathBuf, process}; use toml_edit::{Document, Item}; -use crate::account; +use crate::{account, ui::THEME}; use super::TomlConfig; @@ -32,8 +31,6 @@ macro_rules! wizard_log { }; } -pub(crate) static THEME: Lazy = Lazy::new(ColorfulTheme::default); - pub(crate) async fn configure(path: PathBuf) -> Result { wizard_log!("Configuring your first account:"); @@ -171,22 +168,3 @@ fn set_tables_dotted<'a>(item: &'a mut Item, keys: impl IntoIterator io::Result { - Password::with_theme(&*THEME) - .with_prompt(prompt) - .with_confirmation( - "Confirm password", - "Passwords do not match, please try again.", - ) - .interact() -} - -#[allow(unused)] -pub(crate) fn prompt_secret(prompt: &str) -> io::Result { - Password::with_theme(&*THEME) - .with_prompt(prompt) - .report(false) - .interact() -} diff --git a/src/email/envelope/command/list.rs b/src/email/envelope/command/list.rs index 52602eb..9b0c03a 100644 --- a/src/email/envelope/command/list.rs +++ b/src/email/envelope/command/list.rs @@ -8,7 +8,7 @@ use email::envelope::list::maildir::ListEnvelopesMaildir; use email::envelope::list::notmuch::ListEnvelopesNotmuch; use log::info; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; use crate::{ account::arg::name::AccountNameFlag, @@ -44,7 +44,7 @@ pub struct ListEnvelopesCommand { #[command(flatten)] pub table: TableMaxWidthFlag, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -59,7 +59,7 @@ impl Default for ListEnvelopesCommand { page: 1, page_size: Default::default(), table: Default::default(), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] cache: Default::default(), account: Default::default(), } @@ -72,7 +72,7 @@ impl ListEnvelopesCommand { let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -101,7 +101,7 @@ impl ListEnvelopesCommand { ctx.maildir.as_ref().and_then(ListEnvelopesMaildir::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_list_envelopes(|ctx| { ctx.maildir_for_sync diff --git a/src/email/envelope/command/watch.rs b/src/email/envelope/command/watch.rs index 6e3a5f6..28a3c63 100644 --- a/src/email/envelope/command/watch.rs +++ b/src/email/envelope/command/watch.rs @@ -8,7 +8,7 @@ use email::envelope::watch::maildir::WatchMaildirEnvelopes; use email::envelope::watch::notmuch::WatchNotmuchEnvelopes; use log::info; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; use crate::{ account::arg::name::AccountNameFlag, @@ -27,7 +27,7 @@ pub struct WatchEnvelopesCommand { #[command(flatten)] pub folder: FolderNameOptionalFlag, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -42,7 +42,7 @@ impl WatchEnvelopesCommand { let folder = &self.folder.name; let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -65,7 +65,7 @@ impl WatchEnvelopesCommand { ctx.maildir.as_ref().and_then(WatchMaildirEnvelopes::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_watch_envelopes(|ctx| { ctx.maildir_for_sync diff --git a/src/email/envelope/flag/command/add.rs b/src/email/envelope/flag/command/add.rs index b5af90d..d6bea2d 100644 --- a/src/email/envelope/flag/command/add.rs +++ b/src/email/envelope/flag/command/add.rs @@ -8,7 +8,7 @@ use email::flag::add::maildir::AddFlagsMaildir; use email::flag::add::notmuch::AddFlagsNotmuch; use log::info; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; use crate::{ account::arg::name::AccountNameFlag, @@ -31,7 +31,7 @@ pub struct FlagAddCommand { #[command(flatten)] pub args: IdsAndFlagsArgs, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -47,7 +47,7 @@ impl FlagAddCommand { let (ids, flags) = into_tuple(&self.args.ids_and_flags); let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -67,7 +67,7 @@ impl FlagAddCommand { builder .set_add_flags(|ctx| ctx.maildir.as_ref().and_then(AddFlagsMaildir::new)); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_add_flags(|ctx| { ctx.maildir_for_sync.as_ref().and_then(AddFlagsMaildir::new) diff --git a/src/email/envelope/flag/command/remove.rs b/src/email/envelope/flag/command/remove.rs index 4517fd5..416c757 100644 --- a/src/email/envelope/flag/command/remove.rs +++ b/src/email/envelope/flag/command/remove.rs @@ -8,7 +8,7 @@ use email::flag::remove::maildir::RemoveFlagsMaildir; use email::flag::remove::notmuch::RemoveFlagsNotmuch; use log::info; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; use crate::{ account::arg::name::AccountNameFlag, @@ -31,7 +31,7 @@ pub struct FlagRemoveCommand { #[command(flatten)] pub args: IdsAndFlagsArgs, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -47,7 +47,7 @@ impl FlagRemoveCommand { let (ids, flags) = into_tuple(&self.args.ids_and_flags); let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -69,7 +69,7 @@ impl FlagRemoveCommand { ctx.maildir.as_ref().and_then(RemoveFlagsMaildir::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_remove_flags(|ctx| { ctx.maildir_for_sync diff --git a/src/email/envelope/flag/command/set.rs b/src/email/envelope/flag/command/set.rs index c55c01d..e5a129e 100644 --- a/src/email/envelope/flag/command/set.rs +++ b/src/email/envelope/flag/command/set.rs @@ -8,7 +8,7 @@ use email::flag::set::maildir::SetFlagsMaildir; use email::flag::set::notmuch::SetFlagsNotmuch; use log::info; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; use crate::{ account::arg::name::AccountNameFlag, @@ -31,7 +31,7 @@ pub struct FlagSetCommand { #[command(flatten)] pub args: IdsAndFlagsArgs, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -47,7 +47,7 @@ impl FlagSetCommand { let (ids, flags) = into_tuple(&self.args.ids_and_flags); let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -67,7 +67,7 @@ impl FlagSetCommand { builder .set_set_flags(|ctx| ctx.maildir.as_ref().and_then(SetFlagsMaildir::new)); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_set_flags(|ctx| { ctx.maildir_for_sync.as_ref().and_then(SetFlagsMaildir::new) diff --git a/src/email/message/attachment/command/download.rs b/src/email/message/attachment/command/download.rs index 5ac8a21..448b633 100644 --- a/src/email/message/attachment/command/download.rs +++ b/src/email/message/attachment/command/download.rs @@ -8,7 +8,7 @@ use log::info; use std::{fs, path::PathBuf}; use uuid::Uuid; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; use crate::{ account::arg::name::AccountNameFlag, @@ -31,7 +31,7 @@ pub struct AttachmentDownloadCommand { #[command(flatten)] pub envelopes: EnvelopeIdsArgs, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -48,7 +48,7 @@ impl AttachmentDownloadCommand { let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -72,7 +72,7 @@ impl AttachmentDownloadCommand { builder .set_add_flags(|ctx| ctx.maildir.as_ref().and_then(AddFlagsMaildir::new)); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_peek_messages(|ctx| { ctx.maildir_for_sync diff --git a/src/email/message/command/copy.rs b/src/email/message/command/copy.rs index acf2334..a00b330 100644 --- a/src/email/message/command/copy.rs +++ b/src/email/message/command/copy.rs @@ -6,7 +6,7 @@ use email::message::copy::imap::CopyMessagesImap; use email::message::copy::maildir::CopyMessagesMaildir; use log::info; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; #[allow(unused)] use crate::{ @@ -30,7 +30,7 @@ pub struct MessageCopyCommand { #[command(flatten)] pub envelopes: EnvelopeIdsArgs, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -48,7 +48,7 @@ impl MessageCopyCommand { let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -70,7 +70,7 @@ impl MessageCopyCommand { ctx.maildir.as_ref().and_then(CopyMessagesMaildir::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_copy_messages(|ctx| { ctx.maildir_for_sync diff --git a/src/email/message/command/delete.rs b/src/email/message/command/delete.rs index 28b8e33..841eadf 100644 --- a/src/email/message/command/delete.rs +++ b/src/email/message/command/delete.rs @@ -6,7 +6,7 @@ use email::{flag::add::imap::AddFlagsImap, message::move_::imap::MoveMessagesIma use email::{flag::add::maildir::AddFlagsMaildir, message::move_::maildir::MoveMessagesMaildir}; use log::info; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; #[allow(unused)] use crate::{ @@ -32,7 +32,7 @@ pub struct MessageDeleteCommand { #[command(flatten)] pub envelopes: EnvelopeIdsArgs, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -49,7 +49,7 @@ impl MessageDeleteCommand { let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -74,7 +74,7 @@ impl MessageDeleteCommand { builder .set_add_flags(|ctx| ctx.maildir.as_ref().and_then(AddFlagsMaildir::new)); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_move_messages(|ctx| { ctx.maildir_for_sync diff --git a/src/email/message/command/forward.rs b/src/email/message/command/forward.rs index bdde2e4..b079d9d 100644 --- a/src/email/message/command/forward.rs +++ b/src/email/message/command/forward.rs @@ -10,7 +10,7 @@ use email::message::send::sendmail::SendMessageSendmail; use email::message::send::smtp::SendMessageSmtp; use log::info; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; #[allow(unused)] use crate::{ @@ -44,7 +44,7 @@ pub struct MessageForwardCommand { #[command(flatten)] pub body: MessageRawBodyArg, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -60,7 +60,7 @@ impl MessageForwardCommand { let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -84,7 +84,7 @@ impl MessageForwardCommand { ctx.maildir.as_ref().and_then(AddMaildirMessage::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_add_message(|ctx| { ctx.maildir_for_sync diff --git a/src/email/message/command/mailto.rs b/src/email/message/command/mailto.rs index de81fc4..acc5d82 100644 --- a/src/email/message/command/mailto.rs +++ b/src/email/message/command/mailto.rs @@ -12,7 +12,7 @@ use log::{debug, info}; use mail_builder::MessageBuilder; use url::Url; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; use crate::{ account::arg::name::AccountNameFlag, @@ -34,7 +34,7 @@ pub struct MessageMailtoCommand { #[arg()] pub url: Url, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -46,7 +46,7 @@ impl MessageMailtoCommand { pub fn new(url: &str) -> Result { Ok(Self { url: Url::parse(url)?, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] cache: Default::default(), account: Default::default(), }) @@ -57,7 +57,7 @@ impl MessageMailtoCommand { let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -81,7 +81,7 @@ impl MessageMailtoCommand { ctx.maildir.as_ref().and_then(AddMaildirMessage::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_add_message(|ctx| { ctx.maildir_for_sync diff --git a/src/email/message/command/move_.rs b/src/email/message/command/move_.rs index 6a16d99..fee1983 100644 --- a/src/email/message/command/move_.rs +++ b/src/email/message/command/move_.rs @@ -6,7 +6,7 @@ use email::message::move_::imap::MoveMessagesImap; use email::message::move_::maildir::MoveMessagesMaildir; use log::info; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; #[allow(unused)] use crate::{ @@ -30,7 +30,7 @@ pub struct MessageMoveCommand { #[command(flatten)] pub envelopes: EnvelopeIdsArgs, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -48,7 +48,7 @@ impl MessageMoveCommand { let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -70,7 +70,7 @@ impl MessageMoveCommand { ctx.maildir.as_ref().and_then(MoveMessagesMaildir::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_move_messages(|ctx| { ctx.maildir_for_sync diff --git a/src/email/message/command/read.rs b/src/email/message/command/read.rs index cd8563a..6bd423e 100644 --- a/src/email/message/command/read.rs +++ b/src/email/message/command/read.rs @@ -7,7 +7,7 @@ use email::{flag::add::maildir::AddFlagsMaildir, message::peek::maildir::PeekMes use log::info; use mml::message::FilterParts; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; #[allow(unused)] use crate::{ @@ -76,7 +76,7 @@ pub struct MessageReadCommand { #[arg(conflicts_with = "no_headers")] pub headers: Vec, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -93,7 +93,7 @@ impl MessageReadCommand { let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -119,7 +119,7 @@ impl MessageReadCommand { builder .set_add_flags(|ctx| ctx.maildir.as_ref().and_then(AddFlagsMaildir::new)); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_peek_messages(|ctx| { ctx.maildir_for_sync diff --git a/src/email/message/command/reply.rs b/src/email/message/command/reply.rs index 2bab639..ec4dfba 100644 --- a/src/email/message/command/reply.rs +++ b/src/email/message/command/reply.rs @@ -10,7 +10,7 @@ use email::message::send::sendmail::SendMessageSendmail; use email::message::send::smtp::SendMessageSmtp; use log::info; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; #[allow(unused)] use crate::{ @@ -47,7 +47,7 @@ pub struct MessageReplyCommand { #[command(flatten)] pub body: MessageRawBodyArg, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -62,7 +62,7 @@ impl MessageReplyCommand { let folder = &self.folder.name; let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -86,7 +86,7 @@ impl MessageReplyCommand { ctx.maildir.as_ref().and_then(AddMaildirMessage::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_add_message(|ctx| { ctx.maildir_for_sync diff --git a/src/email/message/command/save.rs b/src/email/message/command/save.rs index 9245e79..b36f90d 100644 --- a/src/email/message/command/save.rs +++ b/src/email/message/command/save.rs @@ -7,7 +7,7 @@ use email::message::add::maildir::AddMaildirMessage; use log::info; use std::io::{self, BufRead, IsTerminal}; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; #[allow(unused)] use crate::{ @@ -30,7 +30,7 @@ pub struct MessageSaveCommand { #[command(flatten)] pub message: MessageRawArg, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -46,7 +46,7 @@ impl MessageSaveCommand { let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -67,7 +67,7 @@ impl MessageSaveCommand { ctx.maildir.as_ref().and_then(AddMaildirMessage::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_add_message(|ctx| { ctx.maildir_for_sync diff --git a/src/email/message/command/send.rs b/src/email/message/command/send.rs index 8effd19..650cfe1 100644 --- a/src/email/message/command/send.rs +++ b/src/email/message/command/send.rs @@ -11,7 +11,7 @@ use email::message::send::smtp::SendMessageSmtp; use log::info; use std::io::{self, BufRead, IsTerminal}; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; #[allow(unused)] use crate::{ @@ -31,7 +31,7 @@ pub struct MessageSendCommand { #[command(flatten)] pub message: MessageRawArg, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -45,7 +45,7 @@ impl MessageSendCommand { let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -75,7 +75,7 @@ impl MessageSendCommand { ctx.maildir.as_ref().and_then(AddMaildirMessage::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_add_message(|ctx| { ctx.maildir_for_sync diff --git a/src/email/message/command/write.rs b/src/email/message/command/write.rs index 8670eb9..a302a4d 100644 --- a/src/email/message/command/write.rs +++ b/src/email/message/command/write.rs @@ -11,7 +11,7 @@ use email::message::send::smtp::SendMessageSmtp; use email::message::Message; use log::info; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; #[allow(unused)] use crate::{ @@ -37,7 +37,7 @@ pub struct MessageWriteCommand { #[command(flatten)] pub body: MessageRawBodyArg, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -51,7 +51,7 @@ impl MessageWriteCommand { let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -75,7 +75,7 @@ impl MessageWriteCommand { ctx.maildir.as_ref().and_then(AddMaildirMessage::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_add_message(|ctx| { ctx.maildir_for_sync diff --git a/src/email/message/template/command/forward.rs b/src/email/message/template/command/forward.rs index 9409641..aea5c17 100644 --- a/src/email/message/template/command/forward.rs +++ b/src/email/message/template/command/forward.rs @@ -6,7 +6,7 @@ use email::message::get::imap::GetMessagesImap; use email::{flag::add::maildir::AddFlagsMaildir, message::peek::maildir::PeekMessagesMaildir}; use log::info; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; #[allow(unused)] use crate::{ @@ -38,7 +38,7 @@ pub struct TemplateForwardCommand { #[command(flatten)] pub body: MessageRawBodyArg, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -54,7 +54,7 @@ impl TemplateForwardCommand { let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -78,7 +78,7 @@ impl TemplateForwardCommand { builder .set_add_flags(|ctx| ctx.maildir.as_ref().and_then(AddFlagsMaildir::new)); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_peek_messages(|ctx| { ctx.maildir_for_sync diff --git a/src/email/message/template/command/reply.rs b/src/email/message/template/command/reply.rs index f91f42b..b73d068 100644 --- a/src/email/message/template/command/reply.rs +++ b/src/email/message/template/command/reply.rs @@ -6,7 +6,7 @@ use email::message::get::imap::GetMessagesImap; use email::{flag::add::maildir::AddFlagsMaildir, message::peek::maildir::PeekMessagesMaildir}; use log::info; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; #[allow(unused)] use crate::{ @@ -42,7 +42,7 @@ pub struct TemplateReplyCommand { #[command(flatten)] pub body: MessageRawBodyArg, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -59,7 +59,7 @@ impl TemplateReplyCommand { let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -83,7 +83,7 @@ impl TemplateReplyCommand { builder .set_add_flags(|ctx| ctx.maildir.as_ref().and_then(AddFlagsMaildir::new)); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_peek_messages(|ctx| { ctx.maildir_for_sync diff --git a/src/email/message/template/command/save.rs b/src/email/message/template/command/save.rs index 8d44ae5..dea5668 100644 --- a/src/email/message/template/command/save.rs +++ b/src/email/message/template/command/save.rs @@ -8,7 +8,7 @@ use log::info; use mml::MmlCompilerBuilder; use std::io::{self, BufRead, IsTerminal}; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; #[allow(unused)] use crate::{ @@ -34,7 +34,7 @@ pub struct TemplateSaveCommand { #[command(flatten)] pub template: TemplateRawArg, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -50,7 +50,7 @@ impl TemplateSaveCommand { let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -71,7 +71,7 @@ impl TemplateSaveCommand { ctx.maildir.as_ref().and_then(AddMaildirMessage::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_add_message(|ctx| { ctx.maildir_for_sync diff --git a/src/email/message/template/command/send.rs b/src/email/message/template/command/send.rs index f7dccb7..4b57ce4 100644 --- a/src/email/message/template/command/send.rs +++ b/src/email/message/template/command/send.rs @@ -12,7 +12,7 @@ use log::info; use mml::MmlCompilerBuilder; use std::io::{self, BufRead, IsTerminal}; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; #[allow(unused)] use crate::{ @@ -34,7 +34,7 @@ pub struct TemplateSendCommand { #[command(flatten)] pub template: TemplateRawArg, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -48,7 +48,7 @@ impl TemplateSendCommand { let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -78,7 +78,7 @@ impl TemplateSendCommand { ctx.maildir.as_ref().and_then(AddMaildirMessage::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_add_message(|ctx| { ctx.maildir_for_sync diff --git a/src/email/message/template/command/write.rs b/src/email/message/template/command/write.rs index 733a3ea..bd91c2a 100644 --- a/src/email/message/template/command/write.rs +++ b/src/email/message/template/command/write.rs @@ -3,7 +3,7 @@ use clap::Parser; use email::message::Message; use log::info; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; use crate::{ account::arg::name::AccountNameFlag, config::TomlConfig, @@ -23,7 +23,7 @@ pub struct TemplateWriteCommand { #[command(flatten)] pub body: TemplateRawBodyArg, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -37,7 +37,7 @@ impl TemplateWriteCommand { let (_, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; diff --git a/src/folder/command/create.rs b/src/folder/command/create.rs index c59aa4f..c0a5986 100644 --- a/src/folder/command/create.rs +++ b/src/folder/command/create.rs @@ -6,9 +6,9 @@ use email::folder::add::imap::AddFolderImap; use email::folder::add::maildir::AddFolderMaildir; use log::info; -#[cfg(any(feature = "imap", feature = "maildir", feature = "sync"))] +#[cfg(any(feature = "imap", feature = "maildir", feature = "account-sync"))] use crate::backend::BackendKind; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; use crate::{ account::arg::name::AccountNameFlag, backend::Backend, config::TomlConfig, @@ -24,7 +24,7 @@ pub struct AddFolderCommand { #[command(flatten)] pub folder: FolderNameArg, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -39,7 +39,7 @@ impl AddFolderCommand { let folder = &self.folder.name; let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -59,7 +59,7 @@ impl AddFolderCommand { builder .set_add_folder(|ctx| ctx.maildir.as_ref().and_then(AddFolderMaildir::new)); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_add_folder(|ctx| { ctx.maildir_for_sync diff --git a/src/folder/command/delete.rs b/src/folder/command/delete.rs index 3b99167..7fe3ff2 100644 --- a/src/folder/command/delete.rs +++ b/src/folder/command/delete.rs @@ -8,9 +8,9 @@ use email::folder::delete::maildir::DeleteFolderMaildir; use log::info; use std::process; -#[cfg(any(feature = "imap", feature = "maildir", feature = "sync"))] +#[cfg(any(feature = "imap", feature = "maildir", feature = "account-sync"))] use crate::backend::BackendKind; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; use crate::{ account::arg::name::AccountNameFlag, backend::Backend, config::TomlConfig, @@ -26,7 +26,7 @@ pub struct FolderDeleteCommand { #[command(flatten)] pub folder: FolderNameArg, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -52,7 +52,7 @@ impl FolderDeleteCommand { let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -74,7 +74,7 @@ impl FolderDeleteCommand { ctx.maildir.as_ref().and_then(DeleteFolderMaildir::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_delete_folder(|ctx| { ctx.maildir_for_sync diff --git a/src/folder/command/expunge.rs b/src/folder/command/expunge.rs index b2dc5ec..ac13562 100644 --- a/src/folder/command/expunge.rs +++ b/src/folder/command/expunge.rs @@ -6,9 +6,9 @@ use email::folder::expunge::imap::ExpungeFolderImap; use email::folder::expunge::maildir::ExpungeFolderMaildir; use log::info; -#[cfg(any(feature = "imap", feature = "maildir", feature = "sync"))] +#[cfg(any(feature = "imap", feature = "maildir", feature = "account-sync"))] use crate::backend::BackendKind; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; use crate::{ account::arg::name::AccountNameFlag, backend::Backend, config::TomlConfig, @@ -25,7 +25,7 @@ pub struct FolderExpungeCommand { #[command(flatten)] pub folder: FolderNameArg, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -40,7 +40,7 @@ impl FolderExpungeCommand { let folder = &self.folder.name; let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -63,7 +63,7 @@ impl FolderExpungeCommand { ctx.maildir.as_ref().and_then(ExpungeFolderMaildir::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_expunge_folder(|ctx| { ctx.maildir_for_sync diff --git a/src/folder/command/list.rs b/src/folder/command/list.rs index c9ef665..bbef9cd 100644 --- a/src/folder/command/list.rs +++ b/src/folder/command/list.rs @@ -6,9 +6,9 @@ use email::folder::list::imap::ListFoldersImap; use email::folder::list::maildir::ListFoldersMaildir; use log::info; -#[cfg(any(feature = "imap", feature = "maildir", feature = "sync"))] +#[cfg(any(feature = "imap", feature = "maildir", feature = "account-sync"))] use crate::backend::BackendKind; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; use crate::{ account::arg::name::AccountNameFlag, @@ -27,7 +27,7 @@ pub struct FolderListCommand { #[command(flatten)] pub table: TableMaxWidthFlag, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -41,7 +41,7 @@ impl FolderListCommand { let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -63,7 +63,7 @@ impl FolderListCommand { ctx.maildir.as_ref().and_then(ListFoldersMaildir::new) }); } - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] Some(BackendKind::MaildirForSync) => { builder.set_list_folders(|ctx| { ctx.maildir_for_sync diff --git a/src/folder/command/purge.rs b/src/folder/command/purge.rs index c666f7d..800c373 100644 --- a/src/folder/command/purge.rs +++ b/src/folder/command/purge.rs @@ -6,9 +6,9 @@ use email::folder::purge::imap::PurgeFolderImap; use log::info; use std::process; -#[cfg(any(feature = "imap", feature = "maildir", feature = "sync"))] +#[cfg(any(feature = "imap", feature = "maildir", feature = "account-sync"))] use crate::backend::BackendKind; -#[cfg(feature = "sync")] +#[cfg(feature = "account-sync")] use crate::cache::arg::disable::CacheDisableFlag; use crate::{ account::arg::name::AccountNameFlag, backend::Backend, config::TomlConfig, @@ -24,7 +24,7 @@ pub struct FolderPurgeCommand { #[command(flatten)] pub folder: FolderNameArg, - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] #[command(flatten)] pub cache: CacheDisableFlag, @@ -50,7 +50,7 @@ impl FolderPurgeCommand { let (toml_account_config, account_config) = config.clone().into_account_configs( self.account.name.as_ref().map(String::as_str), - #[cfg(feature = "sync")] + #[cfg(feature = "account-sync")] self.cache.disable, )?; @@ -73,7 +73,7 @@ impl FolderPurgeCommand { // ctx.maildir.as_ref().and_then(PurgeFolderMaildir::new) // }); // } - // #[cfg(feature = "sync")] + // #[cfg(feature = "account-sync")] // Some(BackendKind::MaildirForSync) => { // builder.set_purge_folder(|ctx| { // ctx.maildir_for_sync diff --git a/src/imap/args.rs b/src/imap/args.rs deleted file mode 100644 index 2dcf556..0000000 --- a/src/imap/args.rs +++ /dev/null @@ -1,62 +0,0 @@ -//! Module related to IMAP CLI. -//! -//! This module provides subcommands and a command matcher related to IMAP. - -use anyhow::Result; -use clap::{value_parser, Arg, ArgMatches, Command}; -use log::debug; - -const ARG_KEEPALIVE: &str = "keepalive"; -const CMD_NOTIFY: &str = "notify"; -const CMD_WATCH: &str = "watch"; - -type Keepalive = u64; - -/// IMAP commands. -pub enum Cmd { - /// Start the IMAP notify mode with the give keepalive duration. - Notify(Keepalive), - /// Start the IMAP watch mode with the give keepalive duration. - Watch(Keepalive), -} - -/// IMAP command matcher. -pub fn matches(m: &ArgMatches) -> Result> { - if let Some(m) = m.subcommand_matches(CMD_NOTIFY) { - let keepalive = m.get_one::(ARG_KEEPALIVE).unwrap(); - debug!("keepalive: {}", keepalive); - return Ok(Some(Cmd::Notify(*keepalive))); - } - - if let Some(m) = m.subcommand_matches(CMD_WATCH) { - let keepalive = m.get_one::(ARG_KEEPALIVE).unwrap(); - debug!("keepalive: {}", keepalive); - return Ok(Some(Cmd::Watch(*keepalive))); - } - - Ok(None) -} - -/// IMAP subcommands. -pub fn subcmds<'a>() -> Vec { - vec![ - Command::new(CMD_NOTIFY) - .about("Notifies when new messages arrive in the given folder") - .alias("idle") - .arg(keepalive_arg()), - Command::new(CMD_WATCH) - .about("Watches IMAP server changes") - .arg(keepalive_arg()), - ] -} - -/// Represents the keepalive argument. -pub fn keepalive_arg() -> Arg { - Arg::new(ARG_KEEPALIVE) - .help("Specifies the keepalive duration.") - .long("keepalive") - .short('k') - .value_name("SECS") - .default_value("500") - .value_parser(value_parser!(u64)) -} diff --git a/src/imap/handlers.rs b/src/imap/handlers.rs deleted file mode 100644 index c39a7ae..0000000 --- a/src/imap/handlers.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! Module related to IMAP handling. -//! -//! This module gathers all IMAP handlers triggered by the CLI. - -use anyhow::Result; - -pub async fn notify(imap: &mut ImapBackend, folder: &str, keepalive: u64) -> Result<()> { - imap.notify(keepalive, folder).await?; - Ok(()) -} - -pub async fn watch(imap: &mut ImapBackend, folder: &str, keepalive: u64) -> Result<()> { - imap.watch(keepalive, folder).await?; - Ok(()) -} diff --git a/src/imap/mod.rs b/src/imap/mod.rs index 7a553c7..7df0104 100644 --- a/src/imap/mod.rs +++ b/src/imap/mod.rs @@ -1,3 +1,2 @@ -// pub mod args; -// pub mod handlers; +#[cfg(feature = "wizard")] pub(crate) mod wizard; diff --git a/src/imap/wizard.rs b/src/imap/wizard.rs index bd6c951..31269b4 100644 --- a/src/imap/wizard.rs +++ b/src/imap/wizard.rs @@ -12,7 +12,7 @@ use secret::Secret; use crate::{ backend::config::BackendConfig, - config::wizard::{prompt_passwd, THEME}, + ui::{prompt, THEME}, wizard_log, wizard_prompt, }; @@ -93,12 +93,12 @@ pub(crate) async fn configure(account_name: &str, email: &str) -> Result { Secret::new_keyring_entry(format!("{account_name}-imap-passwd")) - .set_keyring_entry_secret(prompt_passwd("IMAP password")?) + .set_keyring_entry_secret(prompt::passwd("IMAP password")?) .await?; PasswdConfig::default() } Some(idx) if SECRETS[idx] == RAW => PasswdConfig { - passwd: Secret::Raw(prompt_passwd("IMAP password")?), + passwd: Secret::Raw(prompt::passwd("IMAP password")?), }, Some(idx) if SECRETS[idx] == CMD => PasswdConfig { passwd: Secret::new_cmd( diff --git a/src/maildir/mod.rs b/src/maildir/mod.rs index 73818b4..7df0104 100644 --- a/src/maildir/mod.rs +++ b/src/maildir/mod.rs @@ -1 +1,2 @@ +#[cfg(feature = "wizard")] pub(crate) mod wizard; diff --git a/src/maildir/wizard.rs b/src/maildir/wizard.rs index ee7b260..2ba3af4 100644 --- a/src/maildir/wizard.rs +++ b/src/maildir/wizard.rs @@ -3,7 +3,7 @@ use dialoguer::Input; use dirs::home_dir; use email::maildir::config::MaildirConfig; -use crate::{backend::config::BackendConfig, config::wizard::THEME}; +use crate::{backend::config::BackendConfig, ui::THEME}; pub(crate) fn configure() -> Result { let mut config = MaildirConfig::default(); diff --git a/src/notmuch/mod.rs b/src/notmuch/mod.rs index 73818b4..7df0104 100644 --- a/src/notmuch/mod.rs +++ b/src/notmuch/mod.rs @@ -1 +1,2 @@ +#[cfg(feature = "wizard")] pub(crate) mod wizard; diff --git a/src/sendmail/mod.rs b/src/sendmail/mod.rs index 73818b4..7df0104 100644 --- a/src/sendmail/mod.rs +++ b/src/sendmail/mod.rs @@ -1 +1,2 @@ +#[cfg(feature = "wizard")] pub(crate) mod wizard; diff --git a/src/sendmail/wizard.rs b/src/sendmail/wizard.rs index 1906b71..d1298f4 100644 --- a/src/sendmail/wizard.rs +++ b/src/sendmail/wizard.rs @@ -2,7 +2,7 @@ use anyhow::Result; use dialoguer::Input; use email::sendmail::config::SendmailConfig; -use crate::{backend::config::BackendConfig, config::wizard::THEME}; +use crate::{backend::config::BackendConfig, ui::THEME}; pub(crate) fn configure() -> Result { let mut config = SendmailConfig::default(); diff --git a/src/smtp/mod.rs b/src/smtp/mod.rs index 73818b4..7df0104 100644 --- a/src/smtp/mod.rs +++ b/src/smtp/mod.rs @@ -1 +1,2 @@ +#[cfg(feature = "wizard")] pub(crate) mod wizard; diff --git a/src/smtp/wizard.rs b/src/smtp/wizard.rs index f7d934b..3bb74c4 100644 --- a/src/smtp/wizard.rs +++ b/src/smtp/wizard.rs @@ -12,7 +12,7 @@ use secret::Secret; use crate::{ backend::config::BackendConfig, - config::wizard::{prompt_passwd, THEME}, + ui::{prompt, THEME}, wizard_log, wizard_prompt, }; @@ -93,12 +93,12 @@ pub(crate) async fn configure(account_name: &str, email: &str) -> Result { Secret::new_keyring_entry(format!("{account_name}-smtp-passwd")) - .set_keyring_entry_secret(prompt_passwd("SMTP password")?) + .set_keyring_entry_secret(prompt::passwd("SMTP password")?) .await?; PasswdConfig::default() } Some(idx) if SECRETS[idx] == RAW => PasswdConfig { - passwd: Secret::Raw(prompt_passwd("SMTP password")?), + passwd: Secret::Raw(prompt::passwd("SMTP password")?), }, Some(idx) if SECRETS[idx] == CMD => PasswdConfig { passwd: Secret::new_cmd( diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 565c3f5..e58f35c 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -1,5 +1,11 @@ pub mod choice; pub mod editor; +pub(crate) mod prompt; pub mod table; +use dialoguer::theme::ColorfulTheme; +use once_cell::sync::Lazy; + pub use self::table::*; + +pub(crate) static THEME: Lazy = Lazy::new(ColorfulTheme::default); diff --git a/src/ui/prompt.rs b/src/ui/prompt.rs new file mode 100644 index 0000000..4a1b449 --- /dev/null +++ b/src/ui/prompt.rs @@ -0,0 +1,23 @@ +use dialoguer::Password; +use std::io; + +use super::THEME; + +#[allow(unused)] +pub(crate) fn passwd(prompt: &str) -> io::Result { + Password::with_theme(&*THEME) + .with_prompt(prompt) + .with_confirmation( + "Confirm password", + "Passwords do not match, please try again.", + ) + .interact() +} + +#[allow(unused)] +pub(crate) fn secret(prompt: &str) -> io::Result { + Password::with_theme(&*THEME) + .with_prompt(prompt) + .report(false) + .interact() +}