fix intefrace function

This commit is contained in:
Jonathan Rainville 2018-12-13 13:48:40 -05:00
parent 9c657c310b
commit 3342c28fae
1 changed files with 7 additions and 2 deletions

View File

@ -9,8 +9,9 @@ import Web3 from "web3";
import { Embark, Events } from "../../../typings/embark"; import { Embark, Events } from "../../../typings/embark";
import Suggestions from "./suggestions"; import Suggestions from "./suggestions";
type MatchFunction = (cmd: string) => boolean;
interface HelpDescription { interface HelpDescription {
matches: string[] | any; // (cmd: string): boolean; matches: string[] | MatchFunction;
description: string; description: string;
use?: string; use?: string;
} }
@ -102,7 +103,11 @@ class Console {
"plugin install <package> - " + __("Installs a plugin in the Dapp. eg: plugin install embark-solc"), "plugin install <package> - " + __("Installs a plugin in the Dapp. eg: plugin install embark-solc"),
]; ];
helpDescriptions.forEach((helpDescription) => { helpDescriptions.forEach((helpDescription) => {
helpText.push(`${(helpDescription.use || helpDescription.matches.join("/")).cyan} - ${helpDescription.description}`); let matches = [] as string[];
if (typeof helpDescription.matches === "object") {
matches = helpDescription.matches as string[];
}
helpText.push(`${(helpDescription.use || matches.join("/")).cyan} - ${helpDescription.description}`);
}); });
// Add end commands // Add end commands
helpText.push("quit".cyan + " - " + __("to immediatly exit (alias: exit)"), helpText.push("quit".cyan + " - " + __("to immediatly exit (alias: exit)"),