Merge "Add support for --version in JGit CLI"
This commit is contained in:
commit
ec56d0d82a
|
@ -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://
|
||||
|
|
|
@ -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 @@ private void execute(final String[] argv) throws Exception {
|
|||
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 @@ private void execute(final String[] argv) throws Exception {
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue