Crates.io | synterm |
lib.rs | synterm |
version | 0.3.1 |
source | src |
created_at | 2020-03-27 17:26:08.821011 |
updated_at | 2020-04-21 01:34:10.280794 |
description | A Rust library for making beautiful REPLs and Shells with fish like as you type syntax highlighting |
homepage | |
repository | https://github.com/JesterOrNot/SynTerm |
max_upload_size | |
id | 223576 |
size | 28,412 |
A Rust library for making beautiful REPLs and Shells with fish like as you type syntax highlighting
use std::process::exit;
use synterm::{gen_lexer, gen_parse, syntax_highlight_gen, Color, CommandLineTool};
struct MyTool;
impl CommandLineTool for MyTool {
fn evaluator_function(line: &String) -> String {
match line.as_str() {
"exit" => {
exit(0);
}
_ => format!("Line: {}", line),
}
}
fn syntax_highlight(string: &str) {
syntax_highlight_gen!(
TheLexer,
parser,
(Foo, Color::Red, "foo"),
(Bar, Color::Green, "bar"),
(Baz, Color::Blue, "baz")
);
parser(TheLexer::lexer(string));
}
}
fn main() {
MyTool.start();
}
Add the following to your Cargo.toml's dependency section
synterm = "0.2.11"
logos = "0.9.7"
See TODO.md for ways to contribute
Open it in Gitpod everything is all ready for you!