Skip to content

Commit

Permalink
feat(plugin): add host-print
Browse files Browse the repository at this point in the history
  • Loading branch information
lisiur committed May 15, 2023
1 parent c926f9f commit 197861b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions service/src/plugin/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::io::Write;
use std::time::Duration;

use crate::services::plugin::PluginService;
Expand Down Expand Up @@ -127,6 +128,12 @@ impl Host_Imports for RunningPluginState {
async fn host_select(&mut self, options: Vec<String>) -> wasmtime::Result<Option<String>> {
Ok(self.select(options.iter().map(|x| x.as_str()).collect()))
}

async fn host_print(&mut self, message: String) -> wasmtime::Result<()> {
print!("{}", message);
std::io::stdout().flush().unwrap();
Ok(())
}
}

pub struct RunningPlugin {
Expand Down
1 change: 1 addition & 0 deletions service/src/plugin/wit/host.wit
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ default world host {
import host-loading: func(loading: bool)
import host-input: func(prompt: string) -> option<string>
import host-select: func(options: list<string>) -> option<string>
import host-print: func(message: string)

export run: func()
}

0 comments on commit 197861b

Please sign in to comment.