package fi.helsinki.cs.tmc.cli.command;

import fi.helsinki.cs.tmc.cli.Application;
import fi.helsinki.cs.tmc.cli.command.core.AbstractCommand;
import fi.helsinki.cs.tmc.cli.command.core.Command;
import fi.helsinki.cs.tmc.cli.io.Io;
import fi.helsinki.cs.tmc.cli.io.TmcCliProgressObserver;
import fi.helsinki.cs.tmc.cli.tmcstuff.CourseInfo;
import fi.helsinki.cs.tmc.cli.tmcstuff.CourseInfoIo;
import fi.helsinki.cs.tmc.cli.tmcstuff.TmcUtil;
import fi.helsinki.cs.tmc.cli.tmcstuff.WorkDir;
import fi.helsinki.cs.tmc.core.TmcCore;
import fi.helsinki.cs.tmc.core.domain.Course;
import fi.helsinki.cs.tmc.core.domain.Exercise;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;

import java.util.List;

@Command(name = "update", desc = "Update exercises")
public class UpdateCommand extends AbstractCommand {

    @Override
    public void getOptions(Options options) {
    }

    @Override
    public void run(CommandLine args, Io io) {
        String[] stringArgs = args.getArgs();
        TmcCore core;

        //TODO: Do this in all commands
        if (stringArgs.length > 0) {
            io.println("Use in the course directory");
            return;
        }

        core = getApp().getTmcCore();
        if (core == null) {
            return;
        }

        WorkDir workDir = app.getWorkDir();

        if (workDir.getCourseDirectory() == null) {
            io.println("Not a course directory");
            return;
        }

        CourseInfo info = CourseInfoIo.load(workDir.getConfigFile());
        Course course = info.getCourse();
        List<Exercise> exercises;

        try {
            exercises = core.getExerciseUpdates(new TmcCliProgressObserver(), course).call();
        } catch (Exception e) {
            System.out.println(e);
            return;
        }

        if (exercises.isEmpty()) {
            io.println("All exercises are up-to-date");
            return;
        }

        io.println("Updates available for:");
        for (Exercise exercise : exercises) {
            io.println(exercise.getName());
        }

        System.out.println(TmcUtil.downloadExercises(core, exercises));
    }
}

package fi.helsinki.cs.tmc.cli.command;

import fi.helsinki.cs.tmc.cli.Application;
import fi.helsinki.cs.tmc.cli.command.core.AbstractCommand;
import fi.helsinki.cs.tmc.cli.command.core.Command;
import fi.helsinki.cs.tmc.cli.io.Io;
import fi.helsinki.cs.tmc.cli.io.TmcCliProgressObserver;
import fi.helsinki.cs.tmc.cli.tmcstuff.CourseInfo;
import fi.helsinki.cs.tmc.cli.tmcstuff.CourseInfoIo;
import fi.helsinki.cs.tmc.cli.tmcstuff.TmcUtil;
import fi.helsinki.cs.tmc.cli.tmcstuff.WorkDir;
import fi.helsinki.cs.tmc.core.TmcCore;
import fi.helsinki.cs.tmc.core.domain.Course;
import fi.helsinki.cs.tmc.core.domain.Exercise;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;

import java.util.List;

@Command(name = "update", desc = "Update exercises")
public class UpdateCommand extends AbstractCommand {

    @Override
    public void getOptions(Options options) {
    }

    @Override
    public void run(CommandLine args, Io io) {
        String[] stringArgs = args.getArgs();
        TmcCore core;

        //TODO: Do this in all commands
        if (stringArgs.length > 0) {
            io.println("Use in the course directory");
            return;
        }

        core = getApp().getTmcCore();
        if (core == null) {
            return;
        }

        WorkDir workDir = getApp().getWorkDir();

        if (workDir.getCourseDirectory() == null) {
            io.println("Not a course directory");
            return;
        }

        CourseInfo info = CourseInfoIo.load(workDir.getConfigFile());
        Course course = info.getCourse();
        List<Exercise> exercises;

        try {
            exercises = core.getExerciseUpdates(new TmcCliProgressObserver(), course).call();
        } catch (Exception e) {
            System.out.println(e);
            return;
        }

        if (exercises.isEmpty()) {
            io.println("All exercises are up-to-date");
            return;
        }

        io.println("Updates available for:");
        for (Exercise exercise : exercises) {
            io.println(exercise.getName());
        }

        System.out.println(TmcUtil.downloadExercises(core, exercises));
    }
}

Fix the previous merge.