Skip to content
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

Stop interact_prompt::direct from another thread. #13

Open
ghost opened this issue Apr 26, 2019 · 0 comments
Open

Stop interact_prompt::direct from another thread. #13

ghost opened this issue Apr 26, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Apr 26, 2019

I've tried to override and create a custom handler to stop the input thread, but It is not called unless there is a console input (Enter).

It'd be great if the direct version can be stopped from another thread.

Something like this:

struct InteractHandler {
    stop_signal: Weak<()>,
}

impl interact_prompt::Handler for InteractHandler {
    fn receive_interaction(&self, intr: interact_prompt::Interaction) -> interact_prompt::Response {
        log::info!("called only on console input, newline?");
        if self.stop_signal.upgrade().is_none() {
            interact_prompt::Response::Exit
        } else {
            match intr {
                /*interact_prompt::Interaction::Line(string) => {
                    Commands::new().handle_cmd(&string);
                }*/
                _ => {}
            }
            interact_prompt::Response::Continue
        }
    }
}
@da-x da-x self-assigned this Apr 26, 2019
@da-x da-x added the enhancement New feature or request label Apr 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant