mirror of
https://github.com/lune-org/lune.git
synced 2025-05-04 10:43:57 +01:00
19 lines
605 B
Rust
19 lines
605 B
Rust
use std::io::Write;
|
|
|
|
use lune_utils::fmt::{pretty_format_multi_value, ValueFormatConfig};
|
|
use mlua::prelude::*;
|
|
|
|
const FORMAT_CONFIG: ValueFormatConfig = ValueFormatConfig::new()
|
|
.with_max_depth(4)
|
|
.with_colors_enabled(true);
|
|
|
|
pub fn create(lua: Lua) -> LuaResult<LuaValue> {
|
|
let f = lua.create_function(|_: &Lua, args: LuaMultiValue| {
|
|
let formatted = format!("{}\n", pretty_format_multi_value(&args, &FORMAT_CONFIG));
|
|
let mut stdout = std::io::stdout();
|
|
stdout.write_all(formatted.as_bytes())?;
|
|
stdout.flush()?;
|
|
Ok(())
|
|
})?;
|
|
f.into_lua(&lua)
|
|
}
|