Added list_errors command.

This commit is contained in:
Andrew Lalis 2018-08-30 23:41:22 +02:00
parent 6d42385814
commit 10555a5d0c
3 changed files with 37 additions and 14 deletions

View File

@ -2,10 +2,7 @@ package nl.andrewlalis;
import nl.andrewlalis.model.Organization; import nl.andrewlalis.model.Organization;
import nl.andrewlalis.ui.control.command.CommandExecutor; import nl.andrewlalis.ui.control.command.CommandExecutor;
import nl.andrewlalis.ui.control.command.executables.ArchiveRepos; import nl.andrewlalis.ui.control.command.executables.*;
import nl.andrewlalis.ui.control.command.executables.DefineTaTeams;
import nl.andrewlalis.ui.control.command.executables.GenerateAssignmentsRepo;
import nl.andrewlalis.ui.control.command.executables.ReadStudentsFile;
import nl.andrewlalis.ui.view.InitializerApp; import nl.andrewlalis.ui.view.InitializerApp;
import nl.andrewlalis.util.CommandLine; import nl.andrewlalis.util.CommandLine;
import nl.andrewlalis.util.Logging; import nl.andrewlalis.util.Logging;
@ -40,10 +37,11 @@ public class Main {
app.setAccessToken(userOptions.get("token")); app.setAccessToken(userOptions.get("token"));
// Initialize executable commands. // Initialize executable commands.
executor.registerCommand("read_students", new ReadStudentsFile(InitializerApp.organization)); executor.registerCommand("read_students", new ReadStudentsFile());
executor.registerCommand("archive_all", new ArchiveRepos()); executor.registerCommand("archive_all", new ArchiveRepos());
executor.registerCommand("generate_assignments", new GenerateAssignmentsRepo()); executor.registerCommand("generate_assignments", new GenerateAssignmentsRepo());
executor.registerCommand("define_ta_teams", new DefineTaTeams(app)); executor.registerCommand("define_ta_teams", new DefineTaTeams(app));
executor.registerCommand("list_errors", new ListErrors());
logger.info("GithubManager for Github Repositories in Educational Organizations.\n" + logger.info("GithubManager for Github Repositories in Educational Organizations.\n" +
"© Andrew Lalis (2018), All rights reserved.\n" + "© Andrew Lalis (2018), All rights reserved.\n" +

View File

@ -2,8 +2,6 @@ package nl.andrewlalis.ui.control.command.executables;
import nl.andrewlalis.git_api.GithubManager; import nl.andrewlalis.git_api.GithubManager;
import java.io.IOException;
/** /**
* Represents the action archive all repositories with a certain substring in their name. * Represents the action archive all repositories with a certain substring in their name.
* It takes the following arguments: * It takes the following arguments:
@ -17,12 +15,7 @@ public class ArchiveRepos extends GithubExecutable {
if (args.length < 1) { if (args.length < 1) {
return false; return false;
} }
try { manager.archiveAllRepositories(args[0]);
manager.archiveAllRepositories(args[0]); return true;
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
} }
} }

View File

@ -0,0 +1,32 @@
package nl.andrewlalis.ui.control.command.executables;
import nl.andrewlalis.model.error.Error;
import nl.andrewlalis.ui.control.command.Executable;
import nl.andrewlalis.ui.view.InitializerApp;
import java.util.logging.Logger;
/**
* This executable lists all errors that have occurred so far in the runtime of the program, and have not been resolved.
*/
public class ListErrors implements Executable {
/**
* The logger for outputting debug info.
*/
private static final Logger logger = Logger.getLogger(ListErrors.class.getName());
static {
logger.setParent(Logger.getGlobal());
}
@Override
public boolean execute(String[] args) {
StringBuilder sb = new StringBuilder("Runtime Errors:\n");
for (Error error : InitializerApp.organization.getErrors()) {
sb.append(error);
}
logger.info(sb.toString());
return true;
}
}