diff --git a/schala-repl/Cargo.toml b/schala-repl/Cargo.toml index 1f70e63..9a19c77 100644 --- a/schala-repl/Cargo.toml +++ b/schala-repl/Cargo.toml @@ -11,7 +11,7 @@ itertools = "0.5.8" getopts = "0.2.18" lazy_static = "0.2.8" maplit = "*" -colored = "1.7" +colored = "1.8" serde = "1.0.91" serde_derive = "1.0.91" serde_json = "1.0.15" diff --git a/schala-repl/src/repl/help.rs b/schala-repl/src/repl/help.rs index 89cf33d..68b32a0 100644 --- a/schala-repl/src/repl/help.rs +++ b/schala-repl/src/repl/help.rs @@ -1,5 +1,6 @@ use std::fmt::Write as FmtWrite; +use colored::*; use super::command_tree::CommandTree; use super::{Repl, InterpreterDirectiveOutput}; @@ -10,7 +11,10 @@ pub fn help(repl: &mut Repl, arguments: &[&str]) -> InterpreterDirectiveOutput { let dirs = repl.get_directives(); Some(match get_directive_from_commands(commands, &dirs) { None => format!("Directive `{}` not found", commands.last().unwrap()), - Some(dir) => format!("`{}` - {}", dir.get_cmd(), dir.get_help()) + Some(dir) => { + let mut buf = String::new(); + writeln!(buf, "`{}` - {}", dir.get_cmd(), dir.get_help()).unwrap(); + buf }) } } @@ -32,13 +36,13 @@ fn get_directive_from_commands<'a>(commands: &[&str], dirs: &'a CommandTree) -> fn global_help(repl: &mut Repl) -> InterpreterDirectiveOutput { let mut buf = String::new(); + let sigil = repl.interpreter_directive_sigil; - writeln!(buf, "MetaInterpreter options").unwrap(); + writeln!(buf, "{} version {}", "Schala REPL".bright_red().bold(), crate::VERSION_STRING).unwrap(); writeln!(buf, "-----------------------").unwrap(); for directive in repl.get_directives().get_children() { - let trailer = " "; - writeln!(buf, "{}{}- {}", directive.get_cmd(), trailer, directive.get_help()).unwrap(); + writeln!(buf, "{}{} - {}", sigil, directive.get_cmd(), directive.get_help()).unwrap(); } let ref lang = repl.get_cur_language_state(); diff --git a/schala-repl/src/repl/mod.rs b/schala-repl/src/repl/mod.rs index e8d7073..c9e5368 100644 --- a/schala-repl/src/repl/mod.rs +++ b/schala-repl/src/repl/mod.rs @@ -21,7 +21,7 @@ const OPTIONS_SAVE_FILE: &'static str = ".schala_repl"; type InterpreterDirectiveOutput = Option; pub struct Repl { - interpreter_directive_sigil: char, + pub interpreter_directive_sigil: char, line_reader: ::linefeed::interface::Interface<::linefeed::terminal::DefaultTerminal>, language_states: Vec>, options: ReplOptions,