-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e54d7f
commit cd78fea
Showing
3 changed files
with
33 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
use mlua::prelude::*; | ||
use tokio::io::{self, AsyncWriteExt}; | ||
use tokio::{ | ||
io::{self, AsyncWriteExt}, | ||
task, | ||
}; | ||
|
||
use crate::lune::{scheduler::LuaSchedulerExt, util::formatting::pretty_format_multi_value}; | ||
use crate::lune::util::formatting::pretty_format_multi_value; | ||
|
||
pub fn create(lua: &'static Lua) -> LuaResult<impl IntoLua<'_>> { | ||
lua.create_async_function(|_, args: LuaMultiValue| async move { | ||
pub fn create(lua: &Lua) -> LuaResult<impl IntoLua<'_>> { | ||
lua.create_function(|_, args: LuaMultiValue| { | ||
let formatted = format!("{}\n", pretty_format_multi_value(&args)?); | ||
let mut stdout = io::stdout(); | ||
stdout.write_all(formatted.as_bytes()).await?; | ||
stdout.flush().await?; | ||
task::spawn(async move { | ||
let _res = async move { | ||
let mut stdout = io::stdout(); | ||
stdout.write_all(formatted.as_bytes()).await?; | ||
stdout.flush().await?; | ||
Ok::<_, LuaError>(()) | ||
}; | ||
// FUTURE: Send any error back to scheduler and emit it properly | ||
}); | ||
Ok(()) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,27 @@ | ||
use mlua::prelude::*; | ||
use tokio::io::{self, AsyncWriteExt}; | ||
|
||
use crate::lune::{ | ||
scheduler::LuaSchedulerExt, | ||
util::formatting::{format_label, pretty_format_multi_value}, | ||
use tokio::{ | ||
io::{self, AsyncWriteExt}, | ||
task, | ||
}; | ||
|
||
pub fn create(lua: &'static Lua) -> LuaResult<impl IntoLua<'_>> { | ||
lua.create_async_function(|_, args: LuaMultiValue| async move { | ||
use crate::lune::util::formatting::{format_label, pretty_format_multi_value}; | ||
|
||
pub fn create(lua: &Lua) -> LuaResult<impl IntoLua<'_>> { | ||
lua.create_function(|_, args: LuaMultiValue| { | ||
let formatted = format!( | ||
"{}\n{}\n", | ||
format_label("warn"), | ||
pretty_format_multi_value(&args)? | ||
); | ||
let mut stdout = io::stderr(); | ||
stdout.write_all(formatted.as_bytes()).await?; | ||
stdout.flush().await?; | ||
task::spawn(async move { | ||
let _res = async move { | ||
let mut stdout = io::stderr(); | ||
stdout.write_all(formatted.as_bytes()).await?; | ||
stdout.flush().await?; | ||
Ok::<_, LuaError>(()) | ||
}; | ||
// FUTURE: Send any error back to scheduler and emit it properly | ||
}); | ||
Ok(()) | ||
}) | ||
} |