diff --git a/ohsome-contributions/src/main/java/org/heigit/ohsome/contributions/Contributions2Parquet.java b/ohsome-contributions/src/main/java/org/heigit/ohsome/contributions/Contributions2Parquet.java index 4bade61..e8565ca 100644 --- a/ohsome-contributions/src/main/java/org/heigit/ohsome/contributions/Contributions2Parquet.java +++ b/ohsome-contributions/src/main/java/org/heigit/ohsome/contributions/Contributions2Parquet.java @@ -59,11 +59,12 @@ import static reactor.core.scheduler.Schedulers.parallel; @CommandLine.Command(name = "contributions", aliases = {"contribs"}, - mixinStandardHelpOptions = true, - version = "ohsome-planet contribution 1.0.1", //TODO version should be automatically set see picocli.CommandLine.IVersionProvider description = "generates parquet files") public class Contributions2Parquet implements Callable { + @Option(names = {"-h", "--help"}, usageHelp = true, description = "Show this help message and exit.") + boolean usageHelpRequested; + @Option(names = {"--pbf"}, required = true) private Path pbfPath; @@ -92,6 +93,10 @@ public class Contributions2Parquet implements Callable { @Override public Integer call() throws Exception { + if (usageHelpRequested) { + CommandLine.usage(this, System.out); + return 0; + } var pbf = OSMPbf.open(pbfPath); if (debug) { FileInfo.printInfo(pbf); @@ -289,10 +294,4 @@ private void printBlobInfo(Map> blobTypes) { ); } - public static void main(String[] args) { - var main = new Contributions2Parquet(); - var exit = new CommandLine(main).execute(args); - System.exit(exit); - } - } diff --git a/ohsome-contributions/src/main/java/org/heigit/ohsome/contributions/FileInfo.java b/ohsome-contributions/src/main/java/org/heigit/ohsome/contributions/FileInfo.java index 759a884..65f7792 100644 --- a/ohsome-contributions/src/main/java/org/heigit/ohsome/contributions/FileInfo.java +++ b/ohsome-contributions/src/main/java/org/heigit/ohsome/contributions/FileInfo.java @@ -2,6 +2,7 @@ import com.google.common.collect.Streams; import org.heigit.ohsome.osm.pbf.OSMPbf; +import picocli.CommandLine; import picocli.CommandLine.Command; import picocli.CommandLine.Option; @@ -12,11 +13,20 @@ @Command(name = "fileinfo", description = "print header for osm pbf file") public class FileInfo implements Callable { + + @Option(names = {"-h", "--help"}, usageHelp = true, description = "Show this help message and exit.") + boolean usageHelpRequested; + @Option(names = {"--pbf"}, required = true) private Path path; @Override public Integer call() throws Exception { + if (usageHelpRequested) { + CommandLine.usage(this, System.out); + return 0; + } + var pbf = OSMPbf.open(path); printInfo(pbf); return 0; diff --git a/ohsome-planet-cli/pom.xml b/ohsome-planet-cli/pom.xml index 30bc57a..4dd2fe8 100644 --- a/ohsome-planet-cli/pom.xml +++ b/ohsome-planet-cli/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 org.heigit.ohsome @@ -30,6 +31,38 @@ + + org.codehaus.mojo + buildnumber-maven-plugin + 3.2.1 + + + validate + + create + + + + + 7 + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + + + ${project.parent.artifactId} + ${project.version} + ${buildNumber} + + + + org.apache.maven.plugins maven-shade-plugin @@ -42,7 +75,8 @@ ohsome-planet true - + ${main.class} true diff --git a/ohsome-planet-cli/src/main/java/org/heigit/ohsome/planet/OhsomePlanet.java b/ohsome-planet-cli/src/main/java/org/heigit/ohsome/planet/OhsomePlanet.java index 3c0d7c8..c360336 100644 --- a/ohsome-planet-cli/src/main/java/org/heigit/ohsome/planet/OhsomePlanet.java +++ b/ohsome-planet-cli/src/main/java/org/heigit/ohsome/planet/OhsomePlanet.java @@ -4,13 +4,14 @@ import org.heigit.ohsome.contributions.FileInfo; import picocli.CommandLine; +import java.util.Properties; import java.util.concurrent.Callable; import static picocli.CommandLine.Command; @Command(name = "ohsome-planet", mixinStandardHelpOptions = true, - version = "ohsome-planet 1.0.0", + versionProvider = OhsomePlanet.ManifestVersionProvider.class, description = "Transform OSM (history) PBF files into GeoParquet. Enrich with OSM changeset metadata and country information.%n", subcommands = { FileInfo.class, @@ -29,4 +30,19 @@ public static void main(String[] args) { var exit = new CommandLine(main).execute(args); System.exit(exit); } + + + static class ManifestVersionProvider implements CommandLine.IVersionProvider { + public String[] getVersion() throws Exception { + var url = CommandLine.class.getClassLoader().getResource("META-INF/MANIFEST.MF"); + if (url == null) { + return new String[] {"ohsome-planet"}; + } + try (var stream = url.openStream()){ + var props = new Properties(); + props.load(stream); + return new String[]{"%s %s (rev: %s)".formatted(props.getProperty("application"), props.getProperty("version"), props.getProperty("buildnumber"))}; + } + } + } }