Skip to content

Commit

Permalink
Provide get_completions API in Wormhole object.
Browse files Browse the repository at this point in the history
This API should be used by readline implementations on cli to get possible
completions for user input when user hits TAB key.
  • Loading branch information
copyninja committed May 7, 2018
1 parent a56857c commit 744710c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ impl WormholeCore {
Vec::new()
}

pub fn get_completions(&mut self, prefix: &str) -> Vec<String> {
// We call inputhelper for name plate completions and then execute the
// event it returned to us. Thus we try to link inputhelper with input
// machine.
let (events, completions) = self.inputhelper.get_completions(prefix);

// TODO: This should return empty queue if not we are doing something
// wrong here
assert_eq!(self._execute(events).len(), 0);
completions
}

fn _execute(&mut self, events: Events) -> Vec<Action> {
let mut action_queue: Vec<Action> = Vec::new(); // returned
let mut event_queue: VecDeque<Event> = VecDeque::new();
Expand Down

0 comments on commit 744710c

Please sign in to comment.