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

Trying picocli

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