-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
1 changed file
with
24 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,8 @@ | |
*/ | ||
package com.manorrock.sphynx.cli; | ||
|
||
import java.io.File; | ||
import static java.lang.System.Logger.Level.ERROR; | ||
import java.util.concurrent.Callable; | ||
import picocli.CommandLine; | ||
|
||
|
@@ -36,11 +38,31 @@ | |
* @author Manfred Riem ([email protected]) | ||
*/ | ||
@CommandLine.Command(name = "list", mixinStandardHelpOptions = true) | ||
public class ListCommand implements Callable<Integer> { | ||
public class ListCommand implements Callable<Integer> { | ||
|
||
/** | ||
* Stores the logger. | ||
*/ | ||
private static final System.Logger LOGGER = System.getLogger(CreateCommand.class.getName()); | ||
|
||
/** | ||
* Stores the base directory. | ||
*/ | ||
@CommandLine.Option(names = "--base-directory", description = "The base directory used for storage") | ||
protected File baseDirectory = new File(System.getProperty("user.home") + "/.manorrock/sphynx"); | ||
|
||
@Override | ||
public Integer call() throws Exception { | ||
System.out.println("TODO - list jobs"); | ||
File jobsDirectory = new File(baseDirectory, "jobs"); | ||
if (jobsDirectory.exists()) { | ||
String[] names = jobsDirectory.list(); | ||
for (String name : names) { | ||
System.out.println(name); | ||
} | ||
} else { | ||
LOGGER.log(ERROR, "Job directory does not exist"); | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
} |