]> source.dussan.org Git - jgit.git/commitdiff
Add support for --version in JGit CLI 30/17230/1
authorKaloyan Raev <kaloyan.r@zend.com>
Wed, 9 Oct 2013 10:52:47 +0000 (13:52 +0300)
committerKaloyan Raev <kaloyan.r@zend.com>
Wed, 9 Oct 2013 17:37:03 +0000 (20:37 +0300)
Bug: 419000
Change-Id: I43f5267182ea69d1f9abbff33136e0491c629071
Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java

index bda8f781e0a47f90411534e9b7959ed177adc99c..5154e08c1a82dc0ea5fc25adbe1c551adf589b46 100644 (file)
@@ -258,6 +258,7 @@ usage_displayAListOfAllRegisteredJgitCommands=Display a list of all registered j
 usage_displayAllPossibleMergeBases=display all possible merge bases
 usage_displayThejavaStackTraceOnExceptions=display the Java stack trace on exceptions
 usage_displayThisHelpText=display this help text
+usage_displayVersion=display jgit version
 usage_dstPrefix=show the destination prefix instead of "b/"
 usage_enableTheServiceInAllRepositories=enable the service in all repositories
 usage_exportRepositoriesOverGit=Export repositories over git://
index b948bc2ebba4b5a96371b9319a0c102f3814b154..3648ffd8e4e4289cd4769ead75d304fb0e31a5e5 100644 (file)
@@ -73,6 +73,9 @@ public class Main {
        @Option(name = "--help", usage = "usage_displayThisHelpText", aliases = { "-h" })
        private boolean help;
 
+       @Option(name = "--version", usage = "usage_displayVersion")
+       private boolean version;
+
        @Option(name = "--show-stack-trace", usage = "usage_displayThejavaStackTraceOnExceptions")
        private boolean showStackTrace;
 
@@ -167,7 +170,7 @@ public class Main {
                try {
                        clp.parseArgument(argv);
                } catch (CmdLineException err) {
-                       if (argv.length > 0 && !help) {
+                       if (argv.length > 0 && !help && !version) {
                                writer.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage()));
                                writer.flush();
                                System.exit(1);
@@ -204,6 +207,11 @@ public class Main {
                        System.exit(1);
                }
 
+               if (version) {
+                       String cmdId = Version.class.getSimpleName().toLowerCase();
+                       subcommand = CommandCatalog.get(cmdId).create();
+               }
+
                final TextBuiltin cmd = subcommand;
                if (cmd.requiresRepository())
                        cmd.init(openGitDir(gitdir), null);