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

Commit 15007d6

Browse files
author
Irene
committed
Fix organization command if not logged in
Also small tweaks to prints and tests
1 parent a684873 commit 15007d6

6 files changed

Lines changed: 12 additions & 3 deletions

File tree

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ dependency-reduced-pom.xml
2828
# our tmc-cli log files
2929
/logs/
3030

31-
tmc-langs.logl
31+
tmc-langs.log
32+
/.classpath
33+
/.project
34+
/.settings

src/main/java/fi/helsinki/cs/tmc/cli/backend/SettingsIo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static void saveCurrentSettingsToAccountList(Settings settings) {
7777
Account account = i.next();
7878
if (account.getUsername().equals(settings.getAccount().getUsername())) {
7979
if (!account.getUsername().isPresent()) {
80-
logger.error("Saveable account doesn't exist");
80+
logger.error("Savable account doesn't exist");
8181
return;
8282
}
8383
deletables.add(account);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public void run(CliContext context, CommandLine args) {
6262
ColorUtil.colorString(
6363
"Server " + settings.getServerAddress(), Color.YELLOW));
6464
}
65+
io.println(settings.toString());
6566

6667
printCourseList(settings);
6768
isFirst = false;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ private boolean getSendDiagnosticsAnswer(String username, String server) {
122122
return this.ctx.getSettings().getSendDiagnostics();
123123
}
124124
while (true) {
125-
String sendDiagnostics = io.readLine("Do you want to send crash reports and diagnostics for client development? (y/n)");
125+
String sendDiagnostics = io.readLine("Do you want to send crash reports and diagnostics for client development? (y/n) ");
126126
if (sendDiagnostics.trim().toLowerCase().startsWith("y")) {
127127
return true;
128128
} else if (sendDiagnostics.trim().toLowerCase().startsWith("n")) {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public void getOptions(Options options) {
3232

3333
@Override
3434
public void run(CliContext ctx, CommandLine args) {
35+
if (!ctx.loadBackend()) {
36+
return;
37+
}
3538
Optional<Organization> organization = chooseOrganization(ctx, args);
3639
this.ctx.getSettings().setOrganization(organization);
3740
SettingsIo.saveCurrentSettingsToAccountList(this.ctx.getSettings());
@@ -61,6 +64,7 @@ private void printOrganizations(List<Organization> organizations, boolean pager)
6164
others.add(o);
6265
}
6366
});
67+
io.println("Available Organizations:");
6468
io.println();
6569
pinned.stream().forEach(o -> printFormattedOrganization(o));
6670
io.println("----------");

src/test/java/fi/helsinki/cs/tmc/cli/backend/SettingsIoTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,6 @@ public void saveCurrentSettingsOverridesOldAccountWithSameUsername() {
132132
SettingsIo.saveCurrentSettingsToAccountList(settings);
133133
AccountList newList = SettingsIo.loadAccountList();
134134
assertEquals("new", newList.getAccount("username", STUB_SERVER).getOrganization().get().getName());
135+
SettingsIo.delete();
135136
}
136137
}

0 commit comments

Comments
 (0)