add pretty-print to mers cli

This commit is contained in:
Mark 2024-02-22 16:30:39 +01:00
parent f3f2c13702
commit 7bfdbca3a5
3 changed files with 17 additions and 3 deletions

1
mers/Cargo.toml Executable file → Normal file
View File

@ -14,3 +14,4 @@ repository = "https://github.com/Dummi26/mers"
mers_lib = "0.6.0"
# mers_lib = { path = "../mers_lib" }
clap = { version = "4.3.19", features = ["derive"] }
colored = "2.1.0"

View File

@ -3,6 +3,7 @@ use mers_lib::prelude_compile::*;
use std::{path::PathBuf, process::exit, sync::Arc};
mod cfg_globals;
mod pretty_print;
#[derive(Parser)]
struct Args {
@ -34,6 +35,11 @@ enum Command {
#[command(subcommand)]
source: From,
},
/// Add syntax highlighting to the code
PrettyPrint {
#[command(subcommand)]
source: From,
},
}
#[derive(Subcommand, Clone)]
enum From {
@ -145,5 +151,8 @@ fn main() {
}
}
}
Command::PrettyPrint { source } => {
pretty_print::pretty_print(get_source(source));
}
}
}

View File

@ -1,3 +1,7 @@
print_sum := iter -> iter.sum.println
(1, 2, 3, "a").print_sum
// hello
if some_condition {
{ ref: &my_var }
} else {
[Int] (by_value)
}
// end