Add -q option to suppress banner.

To minimize output when running tests.

Change-Id: Ia97c93cae31722d780ebf9714c6e508bb1630274
This commit is contained in:
Chih-Hung Hsieh
2019-04-02 09:46:15 -07:00
parent 412eba27dc
commit 06ed5b3d2f
2 changed files with 12 additions and 3 deletions

View File

@@ -7,7 +7,7 @@ prolog-shell - Simple interactive Prolog interpreter
[verse]
--
_java_ -jar gerrit.war _prolog-shell_
[-s FILE.pl ...]
[-q] [-s FILE.pl ...]
--
== DESCRIPTION
@@ -15,6 +15,8 @@ Provides a simple interactive Prolog interpreter for development
and testing.
== OPTIONS
-q::
Do not display banner.
-s::
Dynamically load the Prolog source code at startup,
as though the user had entered `['FILE.pl'].` into

View File

@@ -30,9 +30,14 @@ public class PrologShell extends AbstractProgram {
@Option(name = "-s", metaVar = "FILE.pl", usage = "file to load")
private List<String> fileName = new ArrayList<>();
@Option(name = "-q", usage = "quiet mode without banner")
private boolean quiet;
@Override
public int run() {
banner();
if (!quiet) {
banner();
}
BufferingPrologControl pcl = new BufferingPrologControl();
pcl.setPrologClassLoader(new PrologClassLoader(getClass().getClassLoader()));
@@ -55,7 +60,9 @@ public class PrologShell extends AbstractProgram {
try {
pcl.execute(Prolog.BUILTIN, "cafeteria");
write("% halt\n");
if (!quiet) {
write("% halt\n");
}
return 0;
} catch (HaltException halt) {
write("% halt(" + halt.getStatus() + ")\n");