cli/
repl.rs

1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 */
6
7use rustyline::config::Builder;
8use rustyline::validate::{MatchingBracketValidator, ValidationContext, ValidationResult, Validator};
9use rustyline::{Config, Result};
10use rustyline_derive::{Completer, Helper, Highlighter, Hinter};
11
12#[derive(Completer, Helper, Hinter, Highlighter)]
13pub(crate) struct ReplHelper;
14
15impl Validator for ReplHelper {
16	fn validate(&self, ctx: &mut ValidationContext) -> Result<ValidationResult> {
17		MatchingBracketValidator::new().validate(ctx)
18	}
19}
20
21pub(crate) fn rustyline_config() -> Config {
22	let builder = Builder::new();
23	builder.tab_stop(4).build()
24}