Skip to content

Commit

Permalink
added complter, removed reedline crate
Browse files Browse the repository at this point in the history
  • Loading branch information
kernelPanic0x committed Oct 8, 2024
1 parent 6fb8f86 commit e7fefce
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 209 deletions.
212 changes: 4 additions & 208 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ arboard = { optional = true, workspace = true, features = [
] } # Wayland by default, fallback to X11.
tracing = { workspace = true, features = ["log", "log-always"] }
tracing-subscriber = { workspace = true, features = ["env-filter"] }
reedline = "0.35.0"
fuzzt = "0.3.1"

[dev-dependencies]
Expand Down
31 changes: 31 additions & 0 deletions cli/src/completer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use std::sync::LazyLock;

use color_eyre::eyre;
use dialoguer::{Completion, Input};
use magic_wormhole::wordlist::{default_wordlist, Wordlist};

static WORDLIST: LazyLock<Wordlist> = LazyLock::new(|| default_wordlist(2));

struct CustomCompletion {}

impl CustomCompletion {
pub fn default() -> Self {
CustomCompletion {}
}
}

impl Completion for CustomCompletion {
fn get(&self, input: &str) -> Option<String> {
WORDLIST.get_completions(input).first().cloned()
}
}

pub fn enter_code() -> eyre::Result<String> {
let custom_completion = CustomCompletion::default();

Input::new()
.with_prompt("Wormhole Code")
.completion_with(&custom_completion)
.interact_text()
.map_err(From::from)
}

0 comments on commit e7fefce

Please sign in to comment.