Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add top-level --version flag #7

Open
fabiante opened this issue Oct 12, 2023 · 2 comments
Open

Add top-level --version flag #7

fabiante opened this issue Oct 12, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@fabiante
Copy link
Member

fabiante commented Oct 12, 2023

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.

@fabiante fabiante added enhancement New feature or request good first issue Good for newcomers labels Oct 12, 2023
@fabiante
Copy link
Member Author

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.

@fabiante
Copy link
Member Author

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.

@fabiante fabiante removed the good first issue Good for newcomers label Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant