Commit f117faf4 authored by Eric Duminil's avatar Eric Duminil
Browse files

Trying picocli

parent 2fd1f409
Showing with 31 additions and 36 deletions
+31 -36
......@@ -27,6 +27,12 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
<version>4.6.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.osgeo/proj4j -->
<dependency>
<groupId>org.osgeo</groupId>
......
package eu.simstadt.regionchooser;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.logging.Logger;
import java.util.stream.Stream;
import java.util.List;
import java.util.concurrent.Callable;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Parameters;
/*
* Utility class to launch RegionChooser without GUI.
*/
public class RegionChooserCommandLineInterface
@Command(name = "region_chooser", mixinStandardHelpOptions = true, version = "regionChooser x.x", description = "Extracts a region from one or more citygmls.")
class RegionChooserCommandLineInterface implements Callable<Integer>
{
private static final Logger LOGGER = Logger.getLogger(RegionChooserCommandLineInterface.class.getName());
@Parameters(index = "0", description = "SRS Name : 'EPSG:31467' or just 31467")
String srsName;
public static void main(String[] args) throws IOException {
LOGGER.info(String.format("Launching RegionChooser %s", RegionChooserUtils.getApplicationVersion()));
if (args.length == 0) {
displayInfoAndQuit();
}
@Parameters(index = "1", description = "Output file : output.gml")
Path outputCityGML;
Path[] paths = Stream.of(args).map(Paths::get).toArray(Path[]::new);
for (Path path : paths) {
System.out.println(path);
}
//TODO: Also get output file
//TODO: Also get EPSG
//TODO: Also get WKT polygon
@Parameters(index = "2..*", arity = "1..*", description = "The citygml files to extract from : input1.gml input2.gml")
List<Path> citygmls;
// StringBuilder sb = RegionExtractor.selectRegionDirectlyFromCityGML(wktPolygon, srsName, paths);
//
// File buildingIdsFile = selectSaveFileWithDialog(project,
// csvCitygmls.replace(";", "_").replace(".gml", ""), "selected_region");
// RegionChooserUtils.writeStringBuilderToFile(sb, buildingIdsFile.toPath());
@Override
public Integer call() throws Exception { // your business logic goes here...
for (Path file : citygmls) {
System.out.println(file);
}
return 0;
}
private static void displayInfoAndQuit() {
LOGGER.info(
"Please add one directory path as argument. Either a repository path in order to list the available projects:\n"
+ " java -d64 -classpath lib/*;workflows/* eu.simstadt.desktop.SimStadtCommandLineInterface ..\\TestRepository\n"
+ "Or a project path in order to list the available workflows:\n"
+ " java -d64 -classpath lib/*;workflows/* eu.simstadt.desktop.SimStadtCommandLineInterface ..\\TestRepository\\Gruenbuehl.proj\n"
+ "Or a workflow path in order to launch the workflow:\n"
+ " java -d64 -classpath lib/*;workflows/* eu.simstadt.desktop.SimStadtCommandLineInterface ..\\TestRepository\\Gruenbuehl.proj\\a.step");
System.exit(0);
// this example implements Callable, so parsing, error handling and handling user
// requests for usage help or version help can be done with one line of code.
public static void main(String... args) {
int exitCode = new CommandLine(new RegionChooserCommandLineInterface()).execute(args);
System.exit(exitCode);
}
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment