Skip to content

Commit

Permalink
Fixes #288 - Implement list command (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnriem authored Jul 6, 2024
1 parent 6c8cfa1 commit fe83a9f
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions cli/src/main/java/com/manorrock/sphynx/cli/ListCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
}

0 comments on commit fe83a9f

Please sign in to comment.