From a6371574a7c59977c881189a4e87041fefd5a3f7 Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Mon, 16 Jan 2017 04:22:11 -0600 Subject: [PATCH] Allow multiple commands on one line using ` and ` or `;`. --- build.gradle | 2 +- .../wdiwtlt/cli/CommandLineInterface.groovy | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index c53b1aa..938d6fd 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ allprojects { } group = 'com.jdbernard' - version = '0.1.2' + version = '0.1.3' repositories { mavenLocal() diff --git a/cli/src/main/groovy/com/jdbernard/wdiwtlt/cli/CommandLineInterface.groovy b/cli/src/main/groovy/com/jdbernard/wdiwtlt/cli/CommandLineInterface.groovy index 1172ea4..2451f86 100644 --- a/cli/src/main/groovy/com/jdbernard/wdiwtlt/cli/CommandLineInterface.groovy +++ b/cli/src/main/groovy/com/jdbernard/wdiwtlt/cli/CommandLineInterface.groovy @@ -28,7 +28,7 @@ import static com.jdbernard.wdiwtlt.cli.CliErr.* public class CommandLineInterface { - public static final VERSION = "0.1.2" + public static final VERSION = "0.1.3" public static final def DOC = """\ wdiwtlt v$VERSION @@ -97,14 +97,14 @@ Configuration: private String titleStyle, normalStyle, statusStyle, promptStyle, artistStyle, albumStyle, fileStyle, errorStyle, playlistStyle, cmdStyle, optStyle - + private String eraseToEnd = new ANSI().eraseLine(Erase.ToEnd).toString() private String clearLine = new ANSI().eraseLine(Erase.All).toString() private String afterInput = new ANSI().eraseLine(Erase.All).scrollUp().cursorUp().toString() private String beforeLeader = new ANSI().saveCursor().cursorPrevLine(3).toString() private String afterLeader = - new ANSI().restoreCursor().eraseLine(Erase.ToEnd).toString() + new ANSI().restoreCursor().toString() private String eraseLeader = new ANSI().eraseLine(Erase.All).cursorPrevLine().eraseLine(Erase.All) .cursorPrevLine().eraseLine(Erase.All) @@ -391,7 +391,8 @@ Configuration: printLongMessage(errorStyle + errMsg + normalStyle) } else { status.text = errorStyle + errMsg + normalStyle - dismissMsgDate = new Date(new Date().time + msgTimeout) } } } + dismissMsgDate = new Date(new Date().time + msgTimeout) } } + outStream.print eraseToEnd } else { drawLeader() if (curMediaFile && @@ -405,8 +406,13 @@ Configuration: Thread.sleep(250) } } } private def processInput(String line) { + line = line.trim() logger.debug("line: $line") + if (line.indexOf(' and ') > 0 || line.indexOf(';')> 0) { + String[] cmds = line.split(/ and |;/) + return cmds.collect(this.&processInput) } + String[] parts = line.split(' ', 2) String command = parts[0]?.toLowerCase() String rest = parts.size() == 2 ? parts[1]?.trim() : null