mirror of
https://github.com/Dummi26/mers.git
synced 2025-03-10 14:13:52 +01:00
move exit: fn
from base
to stdio
This commit is contained in:
parent
d83f6f942f
commit
4e73ec0201
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "mers"
|
name = "mers"
|
||||||
version = "0.9.9"
|
version = "0.9.10"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "dynamically typed but type-checked programming language"
|
description = "dynamically typed but type-checked programming language"
|
||||||
@ -15,7 +15,7 @@ default = ["colored-output"]
|
|||||||
colored-output = ["mers_lib/ecolor-term", "mers_lib/pretty-print", "dep:colored"]
|
colored-output = ["mers_lib/ecolor-term", "mers_lib/pretty-print", "dep:colored"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
mers_lib = "0.9.9"
|
mers_lib = "0.9.10"
|
||||||
# mers_lib = { path = "../mers_lib" }
|
# mers_lib = { path = "../mers_lib" }
|
||||||
clap = { version = "4.3.19", features = ["derive"] }
|
clap = { version = "4.3.19", features = ["derive"] }
|
||||||
colored = { version = "2.1.0", optional = true }
|
colored = { version = "2.1.0", optional = true }
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "mers_lib"
|
name = "mers_lib"
|
||||||
version = "0.9.9"
|
version = "0.9.10"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "library to use the mers language in other projects"
|
description = "library to use the mers language in other projects"
|
||||||
|
@ -92,9 +92,6 @@ impl Config {
|
|||||||
std::thread::sleep(sleep_dur);
|
std::thread::sleep(sleep_dur);
|
||||||
Ok(())
|
Ok(())
|
||||||
}))
|
}))
|
||||||
.add_var("exit", func_end(|code: IntR<INT_MIN, INT_MAX>, _| {
|
|
||||||
std::process::exit(code.0.try_into().unwrap_or(255));
|
|
||||||
}))
|
|
||||||
.add_var("panic", func_err(|message: &str, _| {
|
.add_var("panic", func_err(|message: &str, _| {
|
||||||
CheckError::from(message)
|
CheckError::from(message)
|
||||||
}))
|
}))
|
||||||
|
@ -4,12 +4,19 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
data::{self, Data, MersDataWInfo, Type},
|
data::{
|
||||||
|
self,
|
||||||
|
int::{INT_MAX, INT_MIN},
|
||||||
|
Data, MersDataWInfo, Type,
|
||||||
|
},
|
||||||
program::{self, run::CheckInfo},
|
program::{self, run::CheckInfo},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
gen::{function::func, OneOrNone},
|
gen::{
|
||||||
|
function::{func, func_end},
|
||||||
|
IntR, OneOrNone,
|
||||||
|
},
|
||||||
Config,
|
Config,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -20,6 +27,7 @@ impl Config {
|
|||||||
/// `eprint: fn` prints to stderr
|
/// `eprint: fn` prints to stderr
|
||||||
/// `debug: fn` debug-prints any value
|
/// `debug: fn` debug-prints any value
|
||||||
/// `read_line: fn` reads a line from stdin and returns it
|
/// `read_line: fn` reads a line from stdin and returns it
|
||||||
|
/// `exit: fn` exits the program with the given exit code. returns `<unreachable>`, just like `panic`
|
||||||
pub fn with_stdio(self) -> Self {
|
pub fn with_stdio(self) -> Self {
|
||||||
self
|
self
|
||||||
// .add_var(
|
// .add_var(
|
||||||
@ -50,6 +58,12 @@ impl Config {
|
|||||||
// inner_statements: None,
|
// inner_statements: None,
|
||||||
// },
|
// },
|
||||||
// )
|
// )
|
||||||
|
.add_var(
|
||||||
|
"exit",
|
||||||
|
func_end(|code: IntR<INT_MIN, INT_MAX>, _| {
|
||||||
|
std::process::exit(code.0.try_into().unwrap_or(255));
|
||||||
|
}),
|
||||||
|
)
|
||||||
.add_var(
|
.add_var(
|
||||||
"read_line",
|
"read_line",
|
||||||
func(|_: (), _| {
|
func(|_: (), _| {
|
||||||
|
Loading…
Reference in New Issue
Block a user