/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.pdfbox.tools;

/**
 * A simple command line utility to get the version of PDFBox.
 *
 * @author Ben Litchfield
 */
final class Version
{
    private Version()
    {
        //should not be constructed.
    }

    /**
     * Get the version of PDFBox or unknown if it is not known.
     *
     * @return The version of pdfbox that is being used.
     */
    public static String getVersion()
    {
        String version = org.apache.pdfbox.util.Version.getVersion();
        if (version != null)
        {
            return version;
        }
        else
        {
            return "unknown";
        }
    }

    /**
     * This will print out the version of PDF to System.out.
     *
     * @param args Command line arguments.
     */
    public static void main(String[] args)
    {
        // suppress the Dock icon on OS X
        System.setProperty("apple.awt.UIElement", "true");

        if( args.length != 0 )
        {
            usage();
            return;
        }
        System.out.println( "Version:" + getVersion() );
    }

    /**
     * This will print out a message telling how to use this example.
     */
    private static void usage()
    {
        System.err.println("Usage: " + Version.class.getName());
        System.exit(1);
    }
}

@@ -834,129 +834,517 @@
 s;%0A%0A
-/**%0A * A simple command line utility to get the version of PDFBox.%0A *%0A * @author Ben Litchfield%0A */%0Afinal class Version%0A%7B
+import java.io.PrintStream;%0Aimport java.util.concurrent.Callable;%0A%0Aimport picocli.CommandLine;%0Aimport picocli.CommandLine.Command;%0A%0A/**%0A * A simple command line utility to get the version of PDFBox.%0A *%0A * @author Ben Litchfield%0A */%0A@Command(name = %22Version%22, description = %22Get the version of PDFBox.%22)%0Afinal class Version implements Callable%3CInteger%3E%0A%7B%0A    // Expected for CLI app to write to System.out/Sytem.err%0A    @SuppressWarnings(%22squid:S106%22)%0A    private static final PrintStream SYSOUT = System.out;%0A
 %0A   
@@ -2094,25 +2094,24 @@
 true%22);%0A
-%0A
         
 if( args
@@ -2106,271 +2106,139 @@
     
-if( args.length != 0 )%0A        %7B%0A            usage();%0A            return;%0A        %7D%0A        System.out.println( %22Version:%22 + getVersion() );%0A    %7D%0A%0A    /**%0A     * This will print out a message telling how to use this example.%0A     */%0A    private static void usage
+%0A        int exitCode = new CommandLine(new Version()).execute(args);%0A        System.exit(exitCode);%0A    %7D%0A%0A    public Integer call
 ()%0A 
@@ -2255,17 +2255,13 @@
    S
-ystem.err
+YSOUT
 .pri
@@ -2270,67 +2270,51 @@
 ln(%22
-Usage: 
+Version:
 %22 + 
+get
 Version
-.class.getName());%0A        System.exit(1)
+());%0A        return 0
 ;%0A  

use picocli for command line parsing