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

Commit 251d158

Browse files
author
Irene
committed
Tweak config and test commands
Ensure that the user is signed in test command. Remove update-date from editable properties, at it is practically alwais overridden. Also fix getting config values bug.
1 parent d5e394e commit 251d158

File tree

4 files changed

+10
-22
lines changed

4 files changed

+10
-22
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ public boolean runAutoUpdate() {
256256
long timestamp = now.getTime();
257257
properties.put(previousUpdateDateKey, Long.toString(timestamp));
258258
context.saveProperties();
259-
260259
return updated;
261260
}
262261

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

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,6 @@ public void setter(String value) throws BadValueTypeException {
9090
SettingsIo.saveCurrentSettingsToAccountList(context.getSettings());
9191
}
9292
});
93-
ALLOWED_KEYS.put(updateDateKey, new PropertyFunctions() {
94-
@Override
95-
public String getter() {
96-
return context.getProperties().get(updateDateKey);
97-
}
98-
99-
@Override
100-
public void setter(String date) throws BadValueTypeException {
101-
if (!date.matches("[0-9]+")) {
102-
throw new BadValueTypeException("Please insert the date as a number");
103-
}
104-
properties.put(updateDateKey, date);
105-
}
106-
});
10793
ALLOWED_KEYS.put(testResultRightKey, new PropertyFunctions() {
10894
@Override
10995
public String getter() {
@@ -222,12 +208,13 @@ public void run(CliContext context, CommandLine args) {
222208
return;
223209
}
224210
String key = args.getOptionValue('g');
225-
boolean exists = properties.containsKey(key);
211+
boolean exists = ALLOWED_KEYS.containsKey(key);
226212
if (!exists && !quiet) {
227213
io.errorln("The property " + key + " doesn't exist.");
228214
return;
229215
}
230-
io.println(exists ? properties.get(key) : "");
216+
String value = ALLOWED_KEYS.get(key).getter();
217+
io.println(exists ? (value != null ? value : "no value set") : "");
231218
return;
232219
} else if (delete) {
233220
deleteProperties(arguments);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public void run(CliContext context, CommandLine args) {
4949
Io io = context.getIo();
5050
ctx = context;
5151

52+
if (!ctx.checkIsLoggedIn(false, true)) {
53+
return;
54+
}
55+
5256
String[] stringArgs = args.getArgs();
5357
if (stringArgs.length == 0 || stringArgs.length > 1) {
5458
io.errorln("You must give a course name as an argument.");
@@ -59,10 +63,6 @@ public void run(CliContext context, CommandLine args) {
5963
ctx = context;
6064
showAll = args.hasOption("a");
6165

62-
if (!ctx.checkIsLoggedIn(false, true)) {
63-
return;
64-
}
65-
6666
WorkDir workDir = ctx.getWorkDir();
6767
if (workDir.getConfigFile() != null) {
6868
io.errorln("Can't download a course inside a course directory.");

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ public void run(CliContext context, CommandLine args) {
4141
return;
4242
}
4343

44-
context.loadUserInformation(true);
44+
if (!context.checkIsLoggedIn(false, true)) {
45+
return;
46+
}
4547

4648
WorkDir workDir = context.getWorkDir();
4749
for (String path : paths) {

0 commit comments

Comments
 (0)