From 32d082e119a52f9f747f4078eeaaf529d9402b6c Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 5 Jun 2019 02:54:13 -0700 Subject: [PATCH] Kill duplicate code --- schala-repl/src/repl/directive_actions.rs | 1 - schala-repl/src/repl/help.rs | 8 ++------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/schala-repl/src/repl/directive_actions.rs b/schala-repl/src/repl/directive_actions.rs index 87269a6..bbac3c3 100644 --- a/schala-repl/src/repl/directive_actions.rs +++ b/schala-repl/src/repl/directive_actions.rs @@ -1,5 +1,4 @@ use super::{Repl, InterpreterDirectiveOutput}; -use crate::repl::command_tree::CommandTree; use crate::repl::help::help; use crate::language::{LangMetaRequest, LangMetaResponse, DebugAsk, DebugResponse}; use itertools::Itertools; diff --git a/schala-repl/src/repl/help.rs b/schala-repl/src/repl/help.rs index ec08741..e14af5c 100644 --- a/schala-repl/src/repl/help.rs +++ b/schala-repl/src/repl/help.rs @@ -11,7 +11,7 @@ pub fn help(repl: &mut Repl, arguments: &[&str]) -> InterpreterDirectiveOutput { }; match arguments { - [] => return global_help(repl), + [] => return global_help(repl, &directives), _ => { writeln!(buf, "Command-specific help not available yet").unwrap(); } @@ -19,12 +19,8 @@ pub fn help(repl: &mut Repl, arguments: &[&str]) -> InterpreterDirectiveOutput { Some(buf) } -fn global_help(repl: &mut Repl) -> InterpreterDirectiveOutput { +fn global_help(repl: &mut Repl, directives: &Vec) -> InterpreterDirectiveOutput { let mut buf = String::new(); - let directives = match repl.get_directives() { - CommandTree::Top(children) => children, - _ => panic!("Top-level CommandTree not Top") - }; writeln!(buf, "MetaInterpreter options").unwrap(); writeln!(buf, "-----------------------").unwrap();