Open fabiante opened 1 year ago
This may be helpful: https://picocli.info/#_dynamic_version_information
I guess that this requires somehow getting the version from the manifest / jar metadata and returning it via the documented interface.
A couple of sources I skimmed through:
Implementing the required interface is kind of easy:
package one.squeeze.pdftools.cli;
import picocli.CommandLine;
/**
* Provides a version for CLI commands based on the manifests implementation version.
*/
public class ManifestVersionProvider implements CommandLine.IVersionProvider {
@Override
public String[] getVersion() throws Exception {
return new String[]{
"some version" + this.getClass().getPackage().getImplementationVersion()
};
}
}
My problem with this is, that using this provider on the root command does not seem to work. I don't know why.
Having an option to call
java -jar pdftools.jar --version
would be nice to figure out what version of the tool is installed.Currently CLI users can not use such a command to figure out what version of this tool is installed.