Make help a bit nicer
This commit is contained in:
parent
f88f2e8550
commit
5271429715
@ -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"
|
||||
|
@ -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();
|
||||
|
@ -21,7 +21,7 @@ const OPTIONS_SAVE_FILE: &'static str = ".schala_repl";
|
||||
type InterpreterDirectiveOutput = Option<String>;
|
||||
|
||||
pub struct Repl {
|
||||
interpreter_directive_sigil: char,
|
||||
pub interpreter_directive_sigil: char,
|
||||
line_reader: ::linefeed::interface::Interface<::linefeed::terminal::DefaultTerminal>,
|
||||
language_states: Vec<Box<ProgrammingLanguageInterface>>,
|
||||
options: ReplOptions,
|
||||
|
Loading…
Reference in New Issue
Block a user