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

import fi.helsinki.cs.tmc.core.TmcCore;
import fi.helsinki.cs.tmc.core.configuration.TmcSettings;
import fi.helsinki.cs.tmc.core.domain.Course;
import fi.helsinki.cs.tmc.core.domain.ProgressObserver;
import fi.helsinki.cs.tmc.langs.util.TaskExecutor;
import fi.helsinki.cs.tmc.langs.util.TaskExecutorImpl;

import java.io.File;
import java.util.List;
import java.util.concurrent.Callable;

/**
 * Command for listing all available courses to user.
 */
public class ListCoursesCommand implements Command {
    @Override
    public String getDescription() {
        return "List the available courses.";
    }

    @Override
    public String getName() {
        return "list-courses";
    }

    @Override
    public void run() {
        Callable<List<Course>> callable;
        TaskExecutor tmcLangs;
        TmcCore core;
        String filename = System.getProperty("user.home") + File.separator + ".tmc";

        tmcLangs = new TaskExecutorImpl();
        //core = new TmcCore(settings, tmcLangs);
        //callable = core.listCourses(ProgressObserver.NULL_OBSERVER);
        //List<Course> list = callable.call();
    }
}

@@ -34,16 +34,66 @@
 mmand;%0A%0A
+import fi.helsinki.cs.tmc.cli.tmcstuff.Settings;%0A%0A
 import f
@@ -866,136 +866,125 @@
     
-TaskExecutor tmcLangs;%0A        TmcCore core;%0A        String filename = System.getProperty(%22user.home%22) + File.separator + %22.tmc%22
+List%3CCourse%3E courses;%0A        TaskExecutor tmcLangs;%0A        Settings settings = new Settings();%0A        TmcCore core
 ;%0A%0A 
@@ -1033,18 +1033,16 @@
         
-//
 core = n
@@ -1081,18 +1081,16 @@
         
-//
 callable
@@ -1154,46 +1154,214 @@
     
-//List%3CCourse%3E list = callable.call();
+try %7B%0A            courses = callable.call();%0A        %7D catch (Exception e) %7B%0A            return;%0A        %7D%0A        for (Course course : courses) %7B%0A            System.out.println(course.getName());%0A        %7D
 %0A   

Implement the list courses command.