Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit e5c4ac4

Browse files
committed
Merge pull request #152 from tmc-cli/print-results-cleanup-juha
Print results cleanup
2 parents 4fe1184 + 3dc606c commit e5c4ac4

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

src/main/java/fi/helsinki/cs/tmc/cli/Application.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ private boolean parseArgs(String[] args) {
8181
try {
8282
line = this.parser.parse(this.options, args);
8383
} catch (ParseException e) {
84-
io.println("Invalid command line arguments." + e);
84+
io.println("Invalid command line arguments.");
85+
io.println(e.getMessage());
8586
return false;
8687
}
8788

@@ -178,9 +179,11 @@ public TmcCore getTmcCore() {
178179

179180
public static void main(String[] args) {
180181
Io io = new TerminalIo();
181-
Runtime.getRuntime().addShutdownHook(new ShutdownHandler(io));
182+
ShutdownHandler shutdownHandler = new ShutdownHandler(io);
183+
Runtime.getRuntime().addShutdownHook(shutdownHandler);
182184
Application app = new Application(io);
183185
app.run(args);
186+
Runtime.getRuntime().removeShutdownHook(shutdownHandler);
184187
}
185188

186189
public static String getVersion() {

src/main/java/fi/helsinki/cs/tmc/cli/command/RunTestsCommand.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import fi.helsinki.cs.tmc.cli.Application;
44
import fi.helsinki.cs.tmc.cli.command.core.Command;
55
import fi.helsinki.cs.tmc.cli.command.core.CommandInterface;
6+
import fi.helsinki.cs.tmc.cli.io.Color;
67
import fi.helsinki.cs.tmc.cli.io.Io;
78
import fi.helsinki.cs.tmc.cli.io.ResultPrinter;
89
import fi.helsinki.cs.tmc.cli.io.TmcCliProgressObserver;
@@ -72,12 +73,13 @@ public void run(String[] args, Io io) {
7273

7374
try {
7475
for (String name : exerciseNames) {
75-
io.println("Testing: " + name);
76+
io.println(Color.colorString("Testing: " + name, Color.ANSI_YELLOW));
7677
name = name.replace("-", File.separator);
7778
Exercise exercise = new Exercise(name, courseName);
7879

7980
runResult = core.runTests(new TmcCliProgressObserver(), exercise).call();
8081
resultPrinter.printRunResult(runResult);
82+
io.println("");
8183
}
8284

8385
} catch (Exception ex) {
@@ -102,7 +104,8 @@ private String[] parseArgs(String[] args) {
102104
try {
103105
line = parser.parse(options, args);
104106
} catch (ParseException e) {
105-
logger.warn("Unable to parse arguments.", e);
107+
io.println("Invalid command line arguments.");
108+
io.println(e.getMessage());
106109
return null;
107110
}
108111
this.showPassed = line.hasOption("a");

src/main/java/fi/helsinki/cs/tmc/cli/command/SubmitCommand.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import fi.helsinki.cs.tmc.cli.Application;
44
import fi.helsinki.cs.tmc.cli.command.core.Command;
55
import fi.helsinki.cs.tmc.cli.command.core.CommandInterface;
6+
import fi.helsinki.cs.tmc.cli.io.Color;
67
import fi.helsinki.cs.tmc.cli.io.Io;
78
import fi.helsinki.cs.tmc.cli.io.ResultPrinter;
89
import fi.helsinki.cs.tmc.cli.tmcstuff.CourseInfo;
@@ -45,6 +46,7 @@ public SubmitCommand(Application app) {
4546

4647
@Override
4748
public void run(String[] args, Io io) {
49+
this.io = io;
4850
TmcCore core;
4951
DirectoryUtil dirUtil;
5052

@@ -53,7 +55,6 @@ public void run(String[] args, Io io) {
5355
if (exerciseNames == null) {
5456
return;
5557
}
56-
this.io = io;
5758
dirUtil = new DirectoryUtil();
5859
core = this.app.getTmcCore();
5960
if (core == null) {
@@ -79,9 +80,10 @@ public void run(String[] args, Io io) {
7980
SubmissionResult result;
8081

8182
for (String exerciseName : exercises) {
82-
io.println("Submitting: " + exerciseName);
83+
io.println(Color.colorString("Submitting: " + exerciseName, Color.ANSI_YELLOW));
8384
result = TmcUtil.submitExercise(core, course, exerciseName);
8485
resultPrinter.printSubmissionResult(result);
86+
io.println("");
8587
}
8688
}
8789

@@ -91,7 +93,8 @@ private String[] parseArgs(String[] args) {
9193
try {
9294
line = parser.parse(options, args);
9395
} catch (ParseException e) {
94-
logger.warn("Unable to parse arguments.", e);
96+
io.println("Invalid command line arguments.");
97+
io.println(e.getMessage());
9598
return null;
9699
}
97100
this.showAll = line.hasOption("a");

0 commit comments

Comments
 (0)