From 7bfdbca3a519e80124f11fe9951cc2760ce7e1e2 Mon Sep 17 00:00:00 2001 From: Mark <> Date: Thu, 22 Feb 2024 16:30:39 +0100 Subject: [PATCH] add pretty-print to mers cli --- mers/Cargo.toml | 1 + mers/src/main.rs | 9 +++++++++ mers/t.mers | 10 +++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) mode change 100755 => 100644 mers/Cargo.toml diff --git a/mers/Cargo.toml b/mers/Cargo.toml old mode 100755 new mode 100644 index c7ba5a7..bcb5df7 --- a/mers/Cargo.toml +++ b/mers/Cargo.toml @@ -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" diff --git a/mers/src/main.rs b/mers/src/main.rs index 7251e59..bce92dd 100755 --- a/mers/src/main.rs +++ b/mers/src/main.rs @@ -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)); + } } } diff --git a/mers/t.mers b/mers/t.mers index f192353..77d738d 100755 --- a/mers/t.mers +++ b/mers/t.mers @@ -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