-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/completion #202
Feat/completion #202
Conversation
this implementation is not ideal because the trait This implementation should be good enough though until this decision is made. |
btw also ran |
7b60577
to
103bb24
Compare
some tests still breaking, will fix soon. @piegamesde maybe it's not worth it to change to |
I think dialoguer is fine for now. It only does completion and not suggestions, meaning that if there are multiple matching values no completion should be performed. This is not optimal, but okay for now (the Python implementation does it like this as well). However, the magic wormhole library should not depend on dialoguer, that dependency should be exclusive to the CLI. Therefore you need to move the respective code out. |
@piegamesde I'm getting a cyclic dependency error when trying to import the CLI code into the root crate to get the |
CLI is separate from the rest on purpose, and if you are getting a cyclic dependency error that indicates you are doing something wrong. The library crate should never depend on the CLI or CLI code, and you trying to import CLI code in the library is what causes your error. |
@piegamesde you are right. I changed to an approach of wrapping the main wordlist struct in a new type so I can implement the |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #202 +/- ##
==========================================
- Coverage 40.52% 40.50% -0.03%
==========================================
Files 23 23
Lines 3326 3343 +17
==========================================
+ Hits 1348 1354 +6
- Misses 1978 1989 +11 ☔ View full report in Codecov by Sentry. |
one |
} | ||
|
||
#[allow(dead_code)] // TODO make this API public one day | ||
pub fn get_completions(&self, prefix: &str) -> Vec<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method should be kept, and the wrapper for Dialoguer in the CLI should make use of it.
num_words, | ||
words: load_pgpwords(), | ||
} | ||
} | ||
|
||
pub fn vecstrings(all: &str) -> Vec<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is really weird. At the very least it should have a descriptive name and documentation to tell what it does, but honestly I think it probably shouldn't exist / not be public in the first place.
struct WordList(PgpWordList); | ||
|
||
impl Default for WordList { | ||
fn default() -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a re-implementation of load_pgpwords
. Why not make use of that?
if completions.len() == 1 { | ||
Some(completions.first().unwrap().clone()) | ||
} else { | ||
// TODO: show vector of suggestions somehow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd consider that out of scope for now.
Closing due to inactivity. This would need an extensive rebase either way. Please discuss the implementation in #147 if you are still interested in this feature. |
closes #147