package com.apfrank.spm;

import java.io.File;
import org.eclipse.jgit.api.Git;


/**
 * Main program of spm.jar.
 */
public class Main {
    
    public static void main(String[] args) throws Exception {
        File tmpDir = null;
        try {
            File srcProjectDir = getProjectDir(args);
            File srcRepoDir = getRepoDir(srcProjectDir);
            Path projectPath = Path.createFrom(srcRepoDir, srcProjectDir);
            tmpDir = FileTools.createTempDir();
            File repoDir = new File(tmpDir, "repo");
            Git git = GitTools.cloneRepository(srcRepoDir, repoDir,
                                               "master");
            File projectDir = projectPath.getFile(repoDir);

            //TodoFile stories = getStoriesFile(projectDir);
            //TodoFile backlog = getBacklogFile(projectDir);
            //Collection<TodoFile> sprints = getSprintFiles(projectDir);

        } finally {
            if (tmpDir != null) {
                FileTools.deleteRecursively(tmpDir);
            }
        }
    }
    
    private static File getProjectDir(String[] args) throws Exception {
        if (args.length != 1) {
            throw new Exception("Usage: java -jar spm.jar <project dir>");
        }
        File dir = new File(args[0]);
        if (!dir.isDirectory()) {
            throw new Exception("Not a directory: " + args[0]);
        }
        return dir.getCanonicalFile();
    }
    
    private static File getRepoDir(File projectDir) throws Exception {
        File repoDir = GitTools.getRepoDir(projectDir);
        if (repoDir == null) {
            throw new Exception("Not in a Git repository: "
                                + projectDir.getPath());
        }
        return repoDir.getCanonicalFile();
    }
    
}
@@ -649,24 +649,25 @@
  %22master%22);%0A
+%0A
             
@@ -670,173 +670,218 @@
     
-File projectDir = projectPath.getFile(repoDir);%0A%0A            //TodoFile stories = getStoriesFile(projectDir);%0A            //TodoFile backlog = getBacklogFile
+// TODO: Implement Project%0A            //Project project = new Project(repoDir, git, projectPath);%0A            %0A            // TODO: Implement Presenter%0A            //Presenter presenter = new Presenter
 (project
 Dir)
@@ -868,35 +868,32 @@
 resenter(project
-Dir
 );%0A            /
@@ -897,68 +897,39 @@
   //
-Collection%3CTodoFile%3E sprints = getSprintFiles(projectDir
+presenter.present(System.out
 );%0A
-%0A
     

Add TODOs