diff --git a/Cargo.lock b/Cargo.lock index f752b50..69ed49b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -174,7 +174,6 @@ dependencies = [ "fuzzy-matcher 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "hkdf 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", @@ -394,12 +393,9 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ncurses 5.99.0 (registry+https://github.com/rust-lang/crates.io-index)", "num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "signal-hook 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -878,11 +874,6 @@ dependencies = [ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "maplit" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "matches" version = "0.1.8" @@ -969,16 +960,6 @@ dependencies = [ "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ncurses" -version = "5.99.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "net2" version = "0.2.33" @@ -1669,16 +1650,6 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "term_size" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "termion" version = "1.5.4" @@ -2131,7 +2102,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e57b3997725d2b60dbec1297f6c2e2957cc383db1cebd6be812163f969c7d586" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" -"checksum maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" "checksum memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9" @@ -2141,7 +2111,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)" = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b2df1a4c22fd44a62147fd8f13dd0f95c9d8ca7b2610299b2a2f9cf8964274e" -"checksum ncurses 5.99.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15699bee2f37e9f8828c7b35b2bc70d13846db453f2d507713b758fabe536b82" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" "checksum num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cf4825417e1e1406b3782a8ce92f4d53f26ec055e3622e1881ca8e9f5f9e08db" "checksum num-complex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fcb0cf31fb3ff77e6d2a6ebd6800df7fdcd106f2ad89113c9130bcd07f93dffc" @@ -2220,7 +2189,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238" "checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" -"checksum term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e5b9a66db815dcfd2da92db471106457082577c3c278d4138ab3e3b4e189327" "checksum termion 1.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "818ef3700c2a7b447dca1a1dd28341fe635e6ee103c806c636bb9c929991b2cd" "checksum thread_local 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "88ddf1ad580c7e3d1efff877d972bcc93f995556b9087a5a259630985c88ceab" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" diff --git a/Cargo.toml b/Cargo.toml index 434e16c..f7ea4af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,15 +7,13 @@ license = "MIT" categories = ["command-line-utilities"] readme = "README.md" repository = "https://github.com/christoph-heiss/bwtui" -description = " terminal-based vault browser for bitwarden" +description = "terminal-based vault browser for bitwarden" [dependencies] aes = "0.3.2" base64 = "0.11.0" block-modes = "0.3.3" -chrono = { version = "0.4.10", features = ["serde"] } clipboard = "0.5.0" -cursive = { version = "0.12.0", features = ["termion-backend"] } cursive_buffered_backend = "0.3.1" cursive_table_view = "0.10.0" directories = "2.0.2" @@ -23,11 +21,25 @@ failure = "0.1.6" fuzzy-matcher = "0.3.1" hkdf = "0.8.0" hmac = "0.7.1" -log = "0.4.8" pbkdf2 = "0.3.0" reqwest = "0.9.24" -serde = { version = "1.0.104", features = ["derive"] } serde_json = "1.0.44" sha2 = "0.8.0" -uuid = { version = "0.8.1", features = ["v4", "serde"] } unicase = "2.6.0" + +[dependencies.chrono] +version = "0.4.10" +features = ["serde"] + +[dependencies.cursive] +version = "0.12.0" +default-features = false +features = ["termion-backend"] + +[dependencies.serde] +version = "1.0.104" +features = ["derive"] + +[dependencies.uuid] +version = "0.8.1" +features = ["v4", "serde"] diff --git a/src/login.rs b/src/login.rs index 1724282..4d0b208 100644 --- a/src/login.rs +++ b/src/login.rs @@ -4,7 +4,6 @@ use cursive::Cursive; use cursive::direction::Orientation; use cursive::event::Event; use cursive::traits::*; -use cursive::view::Selector; use cursive::views::{Dialog, EditView, LinearLayout, OnEventView, TextView}; use crate::{api, vault}; @@ -19,10 +18,9 @@ pub fn ask(siv: &mut Cursive, default_email: Option) { let email_view = OnEventView::new(email_edit) .on_event(Event::CtrlChar('u'), |siv| { - siv.call_on_id("email", |view: &mut EditView| { - view.set_content(""); - }) - .unwrap() + if let Some(mut view) = siv.find_id::("email") { + view.set_content("")(siv); + } }); let password_edit = EditView::new() @@ -32,10 +30,9 @@ pub fn ask(siv: &mut Cursive, default_email: Option) { let password_view = OnEventView::new(password_edit) .on_event(Event::CtrlChar('u'), |siv| { - siv.call_on_id("master_password", |view: &mut EditView| { - view.set_content(""); - }) - .unwrap() + if let Some(mut view) = siv.find_id::("master_password") { + view.set_content("")(siv); + } }); let layout = LinearLayout::new(Orientation::Vertical) @@ -67,7 +64,7 @@ pub fn ask(siv: &mut Cursive, default_email: Option) { ); if default_email.is_some() { - siv.focus(&Selector::Id("master_password")).unwrap(); + siv.focus_id("master_password").unwrap(); } } diff --git a/src/main.rs b/src/main.rs index 6750096..ef6ac25 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,8 +25,6 @@ fn main() { #[cfg(debug_assertions)] siv.add_global_callback(Key::F1, |s| s.toggle_debug_console()); - siv.add_global_callback(Key::Esc, |s| s.quit()); - let mut email = None; if let Ok(data) = api::read_local_vault_data() { email = Some(data.profile.email.clone());