diff options
Diffstat (limited to 'org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm')
42 files changed, 467 insertions, 300 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java index 1e03567500..b572e0092b 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java @@ -3,6 +3,7 @@ * Copyright (C) 2008-2010, Google Inc. * Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com> * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> + * Copyright (C) 2010, Sasa Zivkov <sasa.zivkov@sap.com> * and other copyright owners as documented in the project's IP log. * * This program and the accompanying materials are made available @@ -46,6 +47,8 @@ package org.eclipse.jgit.pgm; +import java.io.PrintWriter; + import org.kohsuke.args4j.Option; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; @@ -55,7 +58,7 @@ import org.eclipse.jgit.transport.TrackingRefUpdate; import org.eclipse.jgit.transport.Transport; abstract class AbstractFetchCommand extends TextBuiltin { - @Option(name = "--verbose", aliases = { "-v" }, usage = "be more verbose") + @Option(name = "--verbose", aliases = { "-v" }, usage = "usage_beMoreVerbose") private boolean verbose; protected void showFetchResult(final Transport tn, final FetchResult r) { @@ -70,8 +73,7 @@ abstract class AbstractFetchCommand extends TextBuiltin { final String dst = abbreviateRef(u.getLocalName(), true); if (!shownURI) { - out.print("From "); - out.print(tn.getURI()); + out.format(CLIText.get().fromURI, tn.getURI()); out.println(); shownURI = true; } @@ -84,6 +86,7 @@ abstract class AbstractFetchCommand extends TextBuiltin { } static void showRemoteMessages(String pkt) { + PrintWriter writer = new PrintWriter(System.err); while (0 < pkt.length()) { final int lf = pkt.indexOf('\n'); final int cr = pkt.indexOf('\r'); @@ -95,18 +98,22 @@ abstract class AbstractFetchCommand extends TextBuiltin { else if (0 <= cr) s = cr; else { - System.err.println("remote: " + pkt); + writer.format(CLIText.get().remoteMessage, pkt); + writer.println(); break; } - if (pkt.charAt(s) == '\r') - System.err.print("remote: " + pkt.substring(0, s) + "\r"); - else - System.err.println("remote: " + pkt.substring(0, s)); + if (pkt.charAt(s) == '\r') { + writer.format(CLIText.get().remoteMessage, pkt.substring(0, s)); + writer.print('\r'); + } else { + writer.format(CLIText.get().remoteMessage, pkt.substring(0, s)); + writer.println(); + } pkt = pkt.substring(s + 1); } - System.err.flush(); + writer.flush(); } private String longTypeOf(final TrackingRefUpdate u) { diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java index 179a32bdbf..cad4b63314 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java @@ -52,23 +52,24 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URLConnection; +import java.text.MessageFormat; import java.util.Properties; import org.eclipse.jgit.transport.AmazonS3; import org.kohsuke.args4j.Argument; -@Command(name = "amazon-s3-client", common = false, usage = "Command line client for Amazon's S3 service") +@Command(name = "amazon-s3-client", common = false, usage = "usage_CommandLineClientForamazonsS3Service") class AmazonS3Client extends TextBuiltin { - @Argument(index = 0, metaVar = "conn.prop", required = true) + @Argument(index = 0, metaVar = "metaVar_connProp", required = true) private File propertyFile; - @Argument(index = 1, metaVar = "OP", required = true) + @Argument(index = 1, metaVar = "metaVar_op", required = true) private String op; - @Argument(index = 2, metaVar = "BUCKET", required = true) + @Argument(index = 2, metaVar = "metaVar_bucket", required = true) private String bucket; - @Argument(index = 3, metaVar = "KEY", required = true) + @Argument(index = 3, metaVar = "metaVar_KEY", required = true) private String key; @Override @@ -89,7 +90,7 @@ class AmazonS3Client extends TextBuiltin { while (len > 0) { final int n = in.read(tmp); if (n < 0) - throw new EOFException("Expected " + len + " bytes."); + throw new EOFException(MessageFormat.format(CLIText.get().expectedNumberOfbytes, len)); System.out.write(tmp, 0, n); len -= n; } @@ -113,7 +114,7 @@ class AmazonS3Client extends TextBuiltin { os.close(); } else { - throw die("Unsupported operation: " + op); + throw die(MessageFormat.format(CLIText.get().unsupportedOperation, op)); } } @@ -128,9 +129,9 @@ class AmazonS3Client extends TextBuiltin { in.close(); } } catch (FileNotFoundException e) { - throw die("no such file: " + propertyFile, e); + throw die(MessageFormat.format(CLIText.get().noSuchFile, propertyFile), e); } catch (IOException e) { - throw die("cannot read " + propertyFile, e); + throw die(MessageFormat.format(CLIText.get().cannotReadBecause, propertyFile, e.getMessage()), e); } } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java index 7a1dd16043..0274219b78 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java @@ -44,6 +44,7 @@ package org.eclipse.jgit.pgm; import java.io.IOException; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -64,28 +65,28 @@ import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.ExampleMode; import org.kohsuke.args4j.Option; -@Command(common = true, usage = "List, create, or delete branches") +@Command(common = true, usage = "usage_listCreateOrDeleteBranches") class Branch extends TextBuiltin { - @Option(name = "--remote", aliases = { "-r" }, usage = "act on remote-tracking branches") + @Option(name = "--remote", aliases = { "-r" }, usage = "usage_actOnRemoteTrackingBranches") private boolean remote = false; - @Option(name = "--all", aliases = { "-a" }, usage = "list both remote-tracking and local branches") + @Option(name = "--all", aliases = { "-a" }, usage = "usage_listBothRemoteTrackingAndLocalBranches") private boolean all = false; - @Option(name = "--delete", aliases = { "-d" }, usage = "delete fully merged branch") + @Option(name = "--delete", aliases = { "-d" }, usage = "usage_deleteFullyMergedBranch") private boolean delete = false; - @Option(name = "--delete-force", aliases = { "-D" }, usage = "delete branch (even if not merged)") + @Option(name = "--delete-force", aliases = { "-D" }, usage = "usage_deleteBranchEvenIfNotMerged") private boolean deleteForce = false; - @Option(name = "--create-force", aliases = { "-f" }, usage = "force create branch even exists") + @Option(name = "--create-force", aliases = { "-f" }, usage = "usage_forceCreateBranchEvenExists") private boolean createForce = false; - @Option(name = "-m", usage = "move/rename a branch") + @Option(name = "-m", usage = "usage_moveRenameABranch") private boolean rename = false; - @Option(name = "--verbose", aliases = { "-v" }, usage = "be verbose") + @Option(name = "--verbose", aliases = { "-v" }, usage = "usage_beVerbose") private boolean verbose = false; @Argument @@ -104,7 +105,7 @@ class Branch extends TextBuiltin { delete(deleteForce); else { if (branches.size() > 2) - throw die("Too many refs given\n" + new CmdLineParser(this).printExample(ExampleMode.ALL)); + throw die(CLIText.get().tooManyRefsGiven + new CmdLineParser(this).printExample(ExampleMode.ALL)); if (rename) { String src, dst; @@ -113,15 +114,15 @@ class Branch extends TextBuiltin { if (head != null && head.isSymbolic()) src = head.getLeaf().getName(); else - throw die("Cannot rename detached HEAD"); + throw die(CLIText.get().cannotRenameDetachedHEAD); dst = branches.get(0); } else { src = branches.get(0); final Ref old = db.getRef(src); if (old == null) - throw die(String.format("%s does not exist", src)); + throw die(MessageFormat.format(CLIText.get().doesNotExist, src)); if (!old.getName().startsWith(Constants.R_HEADS)) - throw die(String.format("%s is not a branch", src)); + throw die(MessageFormat.format(CLIText.get().notABranch, src)); src = old.getName(); dst = branches.get(1); } @@ -129,11 +130,11 @@ class Branch extends TextBuiltin { if (!dst.startsWith(Constants.R_HEADS)) dst = Constants.R_HEADS + dst; if (!Repository.isValidRefName(dst)) - throw die(String.format("%s is not a valid ref name", dst)); + throw die(MessageFormat.format(CLIText.get().notAValidRefName, dst)); RefRename r = db.renameRef(src, dst); if (r.rename() != Result.RENAMED) - throw die(String.format("%s cannot be renamed", src)); + throw die(MessageFormat.format(CLIText.get().cannotBeRenamed, src)); } else if (branches.size() > 0) { String newHead = branches.get(0); @@ -153,16 +154,16 @@ class Branch extends TextBuiltin { if (!newRefName.startsWith(Constants.R_HEADS)) newRefName = Constants.R_HEADS + newRefName; if (!Repository.isValidRefName(newRefName)) - throw die(String.format("%s is not a valid ref name", newRefName)); + throw die(MessageFormat.format(CLIText.get().notAValidRefName, newRefName)); if (!createForce && db.resolve(newRefName) != null) - throw die(String.format("branch %s already exists", newHead)); + throw die(MessageFormat.format(CLIText.get().branchAlreadyExists, newHead)); RefUpdate updateRef = db.updateRef(newRefName); updateRef.setNewObjectId(startAt); updateRef.setForceUpdate(createForce); - updateRef.setRefLogMessage("branch: Created from " + startBranch, false); + updateRef.setRefLogMessage(MessageFormat.format(CLIText.get().branchCreatedFrom, startBranch), false); Result update = updateRef.update(); if (update == Result.REJECTED) - throw die(String.format("Could not create branch %s: %s", newHead, update.toString())); + throw die(MessageFormat.format(CLIText.get().couldNotCreateBranch, newHead, update.toString())); } else { if (verbose) rw = new RevWalk(db); @@ -211,7 +212,7 @@ class Branch extends TextBuiltin { out.print(ref); if (verbose) { final int spaces = maxNameLength - ref.length() + 1; - out.print(String.format("%" + spaces + "s", "")); + out.format("%" + spaces + "s", ""); final ObjectId objectId = refObj.getObjectId(); out.print(objectId.abbreviate(db).name()); out.print(' '); @@ -225,8 +226,7 @@ class Branch extends TextBuiltin { ObjectId head = db.resolve(Constants.HEAD); for (String branch : branches) { if (current.equals(branch)) { - String err = "Cannot delete the branch '%s' which you are currently on."; - throw die(String.format(err, branch)); + throw die(MessageFormat.format(CLIText.get().cannotDeleteTheBranchWhichYouAreCurrentlyOn, branch)); } RefUpdate update = db.updateRef((remote ? Constants.R_REMOTES : Constants.R_HEADS) @@ -235,15 +235,13 @@ class Branch extends TextBuiltin { update.setForceUpdate(force || remote); Result result = update.delete(); if (result == Result.REJECTED) { - String err = "The branch '%s' is not an ancestor of your current HEAD.\n" - + "If you are sure you want to delete it, run 'jgit branch -D %1$s'."; - throw die(String.format(err, branch)); + throw die(MessageFormat.format(CLIText.get().branchIsNotAnAncestorOfYourCurrentHEAD, branch)); } else if (result == Result.NEW) - throw die(String.format("branch '%s' not found.", branch)); + throw die(MessageFormat.format(CLIText.get().branchNotFound, branch)); if (remote) - out.println(String.format("Deleted remote branch %s", branch)); + out.println(MessageFormat.format(CLIText.get().deletedRemoteBranch, branch)); else if (verbose) - out.println(String.format("Deleted branch %s", branch)); + out.println(MessageFormat.format(CLIText.get().deletedBranch, branch)); } } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java new file mode 100644 index 0000000000..8c811d4ef7 --- /dev/null +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2010, Sasa Zivkov <sasa.zivkov@sap.com> + * and other copyright owners as documented in the project's IP log. + * + * This program and the accompanying materials are made available + * under the terms of the Eclipse Distribution License v1.0 which + * accompanies this distribution, is reproduced below, and is + * available at http://www.eclipse.org/org/documents/edl-v10.php + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * - Neither the name of the Eclipse Foundation, Inc. nor the + * names of its contributors may be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.eclipse.jgit.pgm; + +import org.eclipse.jgit.nls.NLS; +import org.eclipse.jgit.nls.TranslationBundle; + +/** + * Translation bundle for JGit command line interface + */ +public class CLIText extends TranslationBundle { + + /** + * @return an instance of this translation bundle + */ + public static CLIText get() { + return NLS.getBundleFor(CLIText.class); + } + + /***/ public String IPZillaPasswordPrompt; + /***/ public String authorInfo; + /***/ public String averageMSPerRead; + /***/ public String branchAlreadyExists; + /***/ public String branchCreatedFrom; + /***/ public String branchIsNotAnAncestorOfYourCurrentHEAD; + /***/ public String branchNotFound; + /***/ public String cacheTreePathInfo; + /***/ public String cannotBeRenamed; + /***/ public String cannotChekoutNoHeadsAdvertisedByRemote; + /***/ public String cannotCreateCommand; + /***/ public String cannotCreateOutputStream; + /***/ public String cannotDeatchHEAD; + /***/ public String cannotDeleteTheBranchWhichYouAreCurrentlyOn; + /***/ public String cannotGuessLocalNameFrom; + /***/ public String cannotLock; + /***/ public String cannotReadBecause; + /***/ public String cannotReadPackageInformation; + /***/ public String cannotRenameDetachedHEAD; + /***/ public String cannotResolve; + /***/ public String cannotSetupConsole; + /***/ public String cannotUseObjectsWithGlog; + /***/ public String cannotWrite; + /***/ public String cantFindGitDirectory; + /***/ public String cantWrite; + /***/ public String commitLabel; + /***/ public String conflictingUsageOf_git_dir_andArguments; + /***/ public String couldNotCreateBranch; + /***/ public String dateInfo; + /***/ public String deletedBranch; + /***/ public String deletedRemoteBranch; + /***/ public String doesNotExist; + /***/ public String everythingUpToDate; + /***/ public String expectedNumberOfbytes; + /***/ public String exporting; + /***/ public String failedToCommitIndex; + /***/ public String failedToLockIndex; + /***/ public String fatalError; + /***/ public String fatalErrorTagExists; + /***/ public String fatalThisProgramWillDestroyTheRepository; + /***/ public String forcedUpdate; + /***/ public String fromURI; + /***/ public String initializedEmptyGitRepositoryIn; + /***/ public String invalidHttpProxyOnlyHttpSupported; + /***/ public String jgitVersion; + /***/ public String listeningOn; + /***/ public String metaVar_command; + /***/ public String metaVar_commitish; + /***/ public String metaVar_object; + /***/ public String metaVar_paths; + /***/ public String metaVar_refspec; + /***/ public String metaVar_treeish; + /***/ public String mostCommonlyUsedCommandsAre; + /***/ public String needApprovalToDestroyCurrentRepository; + /***/ public String noGitRepositoryConfigured; + /***/ public String noSuchFile; + /***/ public String noTREESectionInIndex; + /***/ public String nonFastForward; + /***/ public String notABranch; + /***/ public String notACommit; + /***/ public String notAGitRepository; + /***/ public String notAJgitCommand; + /***/ public String notARevision; + /***/ public String notATagVersionIsRequired; + /***/ public String notATree; + /***/ public String notAValidRefName; + /***/ public String notAnIndexFile; + /***/ public String notAnObject; + /***/ public String notFound; + /***/ public String onlyOneMetaVarExpectedIn; + /***/ public String pushTo; + /***/ public String remoteMessage; + /***/ public String remoteRefObjectChangedIsNotExpectedOne; + /***/ public String remoteSideDoesNotSupportDeletingRefs; + /***/ public String repaint; + /***/ public String serviceNotSupported; + /***/ public String skippingObject; + /***/ public String timeInMilliSeconds; + /***/ public String tooManyRefsGiven; + /***/ public String unsupportedOperation; + /***/ public String warningNoCommitGivenOnCommandLine; +} diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java index a6c50ff19a..b0f51ec58a 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java @@ -46,6 +46,7 @@ package org.eclipse.jgit.pgm; import java.io.File; import java.io.IOException; import java.net.URISyntaxException; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -70,15 +71,15 @@ import org.eclipse.jgit.transport.RemoteConfig; import org.eclipse.jgit.transport.Transport; import org.eclipse.jgit.transport.URIish; -@Command(common = true, usage = "Clone a repository into a new directory") +@Command(common = true, usage = "usage_cloneRepositoryIntoNewDir") class Clone extends AbstractFetchCommand { - @Option(name = "--origin", aliases = { "-o" }, metaVar = "name", usage = "use <name> instead of 'origin' to track upstream") + @Option(name = "--origin", aliases = { "-o" }, metaVar = "metaVar_remoteName", usage = "usage_useNameInsteadOfOriginToTrackUpstream") private String remoteName = Constants.DEFAULT_REMOTE_NAME; - @Argument(index = 0, required = true, metaVar = "uri-ish") + @Argument(index = 0, required = true, metaVar = "metaVar_uriish") private String sourceUri; - @Argument(index = 1, metaVar = "directory") + @Argument(index = 1, metaVar = "metaVar_directory") private String localName; @Override @@ -89,14 +90,14 @@ class Clone extends AbstractFetchCommand { @Override protected void run() throws Exception { if (localName != null && gitdir != null) - throw die("conflicting usage of --git-dir and arguments"); + throw die(CLIText.get().conflictingUsageOf_git_dir_andArguments); final URIish uri = new URIish(sourceUri); if (localName == null) { try { localName = uri.getHumanishName(); } catch (IllegalArgumentException e) { - throw die("cannot guess local name from " + sourceUri); + throw die(MessageFormat.format(CLIText.get().cannotGuessLocalNameFrom, sourceUri)); } } if (gitdir == null) @@ -107,8 +108,8 @@ class Clone extends AbstractFetchCommand { db.getConfig().setBoolean("core", null, "bare", false); db.getConfig().save(); - out.println("Initialized empty Git repository in " - + gitdir.getAbsolutePath()); + out.format(CLIText.get().initializedEmptyGitRepositoryIn, gitdir.getAbsolutePath()); + out.println(); out.flush(); saveRemote(uri); @@ -163,7 +164,7 @@ class Clone extends AbstractFetchCommand { private void doCheckout(final Ref branch) throws IOException { if (branch == null) - throw die("cannot checkout; no HEAD advertised by remote"); + throw die(CLIText.get().cannotChekoutNoHeadsAdvertisedByRemote); if (!Constants.HEAD.equals(branch.getName())) { RefUpdate u = db.updateRef(Constants.HEAD); u.disableRefLog(); @@ -183,4 +184,4 @@ class Clone extends AbstractFetchCommand { co.checkout(); index.write(); } -} +}
\ No newline at end of file diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java index eb68ada9b7..eace2e1f25 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.pgm; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +import java.text.MessageFormat; /** * Description of a command (a {@link TextBuiltin} subclass. @@ -140,9 +141,9 @@ public class CommandRef { try { c = impl.getDeclaredConstructor(); } catch (SecurityException e) { - throw new RuntimeException("Cannot create command " + getName(), e); + throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e)); } catch (NoSuchMethodException e) { - throw new RuntimeException("Cannot create command " + getName(), e); + throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e)); } c.setAccessible(true); @@ -150,13 +151,13 @@ public class CommandRef { try { r = c.newInstance(); } catch (InstantiationException e) { - throw new RuntimeException("Cannot create command " + getName(), e); + throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e)); } catch (IllegalAccessException e) { - throw new RuntimeException("Cannot create command " + getName(), e); + throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e)); } catch (IllegalArgumentException e) { - throw new RuntimeException("Cannot create command " + getName(), e); + throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e)); } catch (InvocationTargetException e) { - throw new RuntimeException("Cannot create command " + getName(), e); + throw new RuntimeException(MessageFormat.format(CLIText.get().cannotCreateCommand, getName(), e)); } r.setCommandName(getName()); return r; diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java index 88219bdd9a..f015a9e7bd 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.pgm; import java.io.File; import java.net.InetSocketAddress; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; @@ -52,33 +53,33 @@ import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option; import org.eclipse.jgit.transport.DaemonService; -@Command(common = true, usage = "Export repositories over git://") +@Command(common = true, usage = "usage_exportRepositoriesOverGit") class Daemon extends TextBuiltin { - @Option(name = "--port", metaVar = "PORT", usage = "port number to listen on") + @Option(name = "--port", metaVar = "metaVar_port", usage = "usage_portNumberToListenOn") int port = org.eclipse.jgit.transport.Daemon.DEFAULT_PORT; - @Option(name = "--listen", metaVar = "HOSTNAME", usage = "hostname (or ip) to listen on") + @Option(name = "--listen", metaVar = "metaVar_hostName", usage = "usage_hostnameOrIpToListenOn") String host; - @Option(name = "--timeout", metaVar = "SECONDS", usage = "abort connection if no activity") + @Option(name = "--timeout", metaVar = "metaVar_seconds", usage = "usage_abortConnectionIfNoActivity") int timeout = -1; - @Option(name = "--enable", metaVar = "SERVICE", usage = "enable the service in all repositories", multiValued = true) + @Option(name = "--enable", metaVar = "metaVar_service", usage = "usage_enableTheServiceInAllRepositories", multiValued = true) final List<String> enable = new ArrayList<String>(); - @Option(name = "--disable", metaVar = "SERVICE", usage = "disable the service in all repositories", multiValued = true) + @Option(name = "--disable", metaVar = "metaVar_service", usage = "usage_disableTheServiceInAllRepositories", multiValued = true) final List<String> disable = new ArrayList<String>(); - @Option(name = "--allow-override", metaVar = "SERVICE", usage = "configure the service in daemon.servicename", multiValued = true) + @Option(name = "--allow-override", metaVar = "metaVar_service", usage = "usage_configureTheServiceInDaemonServicename", multiValued = true) final List<String> canOverride = new ArrayList<String>(); - @Option(name = "--forbid-override", metaVar = "SERVICE", usage = "configure the service in daemon.servicename", multiValued = true) + @Option(name = "--forbid-override", metaVar = "metaVar_service", usage = "usage_configureTheServiceInDaemonServicename", multiValued = true) final List<String> forbidOverride = new ArrayList<String>(); - @Option(name = "--export-all", usage = "export without git-daemon-export-ok") + @Option(name = "--export-all", usage = "usage_exportWithoutGitDaemonExportOk") boolean exportAll; - @Argument(required = true, metaVar = "DIRECTORY", usage = "directories to export") + @Argument(required = true, metaVar = "metaVar_directory", usage = "usage_directoriesToExport") final List<File> directory = new ArrayList<File>(); @Override @@ -108,18 +109,18 @@ class Daemon extends TextBuiltin { service(d, n).setOverridable(false); for (final File f : directory) { - out.println("Exporting " + f.getAbsolutePath()); + out.println(MessageFormat.format(CLIText.get().exporting, f.getAbsolutePath())); d.exportDirectory(f); } d.start(); - out.println("Listening on " + d.getAddress()); + out.println(MessageFormat.format(CLIText.get().listeningOn, d.getAddress())); } private DaemonService service(final org.eclipse.jgit.transport.Daemon d, final String n) { final DaemonService svc = d.getService(n); if (svc == null) - throw die("Service '" + n + "' not supported"); + throw die(MessageFormat.format(CLIText.get().serviceNotSupported, n)); return svc; } -} +}
\ No newline at end of file diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java index 24bcdcc612..a5db453688 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java @@ -64,17 +64,17 @@ import org.eclipse.jgit.treewalk.TreeWalk; import org.eclipse.jgit.treewalk.filter.AndTreeFilter; import org.eclipse.jgit.treewalk.filter.TreeFilter; -@Command(common = true, usage = "Show diffs") +@Command(common = true, usage = "usage_ShowDiffs") class Diff extends TextBuiltin { - @Argument(index = 0, metaVar = "tree-ish", required = true) + @Argument(index = 0, metaVar = "metaVar_treeish", required = true) void tree_0(final AbstractTreeIterator c) { trees.add(c); } - @Argument(index = 1, metaVar = "tree-ish", required = true) + @Argument(index = 1, metaVar = "metaVar_treeish", required = true) private final List<AbstractTreeIterator> trees = new ArrayList<AbstractTreeIterator>(); - @Option(name = "--", metaVar = "path", multiValued = true, handler = PathTreeFilterHandler.class) + @Option(name = "--", metaVar = "metaVar_port", multiValued = true, handler = PathTreeFilterHandler.class) private TreeFilter pathFilter = TreeFilter.ALL; private DiffFormatter fmt = new DiffFormatter(); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/DiffTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/DiffTree.java index 13b1c780f0..a7c40acdb3 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/DiffTree.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/DiffTree.java @@ -57,18 +57,18 @@ import org.eclipse.jgit.treewalk.filter.AndTreeFilter; import org.eclipse.jgit.treewalk.filter.TreeFilter; class DiffTree extends TextBuiltin { - @Option(name = "--recursive", usage = "recurse into subtrees", aliases = { "-r" }) + @Option(name = "--recursive", usage = "usage_recurseIntoSubtrees", aliases = { "-r" }) private boolean recursive; - @Argument(index = 0, metaVar = "tree-ish", required = true) + @Argument(index = 0, metaVar = "metaVar_treeish", required = true) void tree_0(final AbstractTreeIterator c) { trees.add(c); } - @Argument(index = 1, metaVar = "tree-ish", required = true) + @Argument(index = 1, metaVar = "metaVar_treeish", required = true) private final List<AbstractTreeIterator> trees = new ArrayList<AbstractTreeIterator>(); - @Option(name = "--", metaVar = "path", multiValued = true, handler = PathTreeFilterHandler.class) + @Option(name = "--", metaVar = "metaVar_path", multiValued = true, handler = PathTreeFilterHandler.class) private TreeFilter pathFilter = TreeFilter.ALL; @Override diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java index 6ed468510f..a68145bf71 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java @@ -55,12 +55,12 @@ import org.eclipse.jgit.transport.FetchResult; import org.eclipse.jgit.transport.RefSpec; import org.eclipse.jgit.transport.Transport; -@Command(common = true, usage = "Update remote refs from another repository") +@Command(common = true, usage = "usage_updateRemoteRefsFromAnotherRepository") class Fetch extends AbstractFetchCommand { - @Option(name = "--timeout", metaVar = "SECONDS", usage = "abort connection if no activity") + @Option(name = "--timeout", metaVar = "metaVar_seconds", usage = "usage_abortConnectionIfNoActivity") int timeout = -1; - @Option(name = "--fsck", usage = "perform fsck style checks on receive") + @Option(name = "--fsck", usage = "usage_performFsckStyleChecksOnReceive") private Boolean fsck; @Option(name = "--no-fsck") @@ -68,13 +68,13 @@ class Fetch extends AbstractFetchCommand { fsck = Boolean.FALSE; } - @Option(name = "--prune", usage = "prune stale tracking refs") + @Option(name = "--prune", usage = "usage_pruneStaleTrackingRefs") private Boolean prune; @Option(name = "--dry-run") private boolean dryRun; - @Option(name = "--thin", usage = "fetch thin pack") + @Option(name = "--thin", usage = "usage_fetchThinPack") private Boolean thin; @Option(name = "--no-thin") @@ -82,10 +82,10 @@ class Fetch extends AbstractFetchCommand { thin = Boolean.FALSE; } - @Argument(index = 0, metaVar = "uri-ish") + @Argument(index = 0, metaVar = "metaVar_uriish") private String remote = Constants.DEFAULT_REMOTE_NAME; - @Argument(index = 1, metaVar = "refspec") + @Argument(index = 1, metaVar = "metaVar_refspec") private List<RefSpec> toget; @Override diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java index caf4f30e3b..3dfd8ff62d 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java @@ -84,7 +84,7 @@ class Glog extends RevWalkTextBuiltin { final JPanel buttons = new JPanel(new FlowLayout()); final JButton repaint = new JButton(); - repaint.setText("Repaint"); + repaint.setText(CLIText.get().repaint); repaint.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { graphPane.repaint(); @@ -118,7 +118,7 @@ class Glog extends RevWalkTextBuiltin { @Override protected RevWalk createWalk() { if (objects) - throw die("Cannot use --objects with glog"); + throw die(CLIText.get().cannotUseObjectsWithGlog); final PlotWalk w = new PlotWalk(db); w.sort(RevSort.BOUNDARY, true); return w; diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java index eb65e680ff..35fd2a5971 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java @@ -52,13 +52,13 @@ import org.kohsuke.args4j.Option; import org.eclipse.jgit.lib.TextProgressMonitor; class IndexPack extends TextBuiltin { - @Option(name = "--fix-thin", usage = "fix a thin pack to be complete") + @Option(name = "--fix-thin", usage = "usage_fixAThinPackToBeComplete") private boolean fixThin; - @Option(name = "--index-version", usage = "index file format to create") + @Option(name = "--index-version", usage = "usage_indexFileFormatToCreate") private int indexVersion = -1; - @Argument(index = 0, required = true, metaVar = "base") + @Argument(index = 0, required = true, metaVar = "metaVar_base") private File base; @Override diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java index a8fe7d8a53..d8c7bdfb4a 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java @@ -46,14 +46,15 @@ package org.eclipse.jgit.pgm; import java.io.File; +import java.text.MessageFormat; import org.kohsuke.args4j.Option; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Repository; -@Command(common = true, usage = "Create an empty git repository") +@Command(common = true, usage = "usage_CreateAnEmptyGitRepository") class Init extends TextBuiltin { - @Option(name = "--bare", usage = "Create a bare repository") + @Option(name = "--bare", usage = "usage_CreateABareRepository") private boolean bare; @Override @@ -67,7 +68,6 @@ class Init extends TextBuiltin { gitdir = new File(bare ? "." : Constants.DOT_GIT); db = new Repository(gitdir); db.create(bare); - out.println("Initialized empty Git repository in " - + gitdir.getAbsolutePath()); + out.println(MessageFormat.format(CLIText.get().initializedEmptyGitRepositoryIn, gitdir.getAbsolutePath())); } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java index 4b5975669f..9aa197e4ab 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java @@ -46,6 +46,7 @@ package org.eclipse.jgit.pgm; import java.text.DateFormat; +import java.text.MessageFormat; import java.text.SimpleDateFormat; import java.util.Collection; import java.util.Iterator; @@ -61,7 +62,7 @@ import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevWalk; -@Command(common = true, usage = "View commit history") +@Command(common = true, usage = "usage_viewCommitHistory") class Log extends RevWalkTextBuiltin { private final TimeZone myTZ = TimeZone.getDefault(); @@ -69,7 +70,7 @@ class Log extends RevWalkTextBuiltin { private Map<AnyObjectId, Set<Ref>> allRefsByPeeledObjectId; - @Option(name="--decorate", usage="Show ref names matching commits") + @Option(name="--decorate", usage="usage_showRefNamesMatchingCommits") private boolean decorate; Log() { @@ -86,7 +87,8 @@ class Log extends RevWalkTextBuiltin { @Override protected void show(final RevCommit c) throws Exception { - out.print("commit "); + out.print(CLIText.get().commitLabel); + out.print(" "); c.getId().copyTo(outbuffer, out); if (decorate) { Collection<Ref> list = allRefsByPeeledObjectId.get(c.copy()); @@ -103,18 +105,11 @@ class Log extends RevWalkTextBuiltin { out.println(); final PersonIdent author = c.getAuthorIdent(); - out.print("Author: "); - out.print(author.getName()); - out.print(" <"); - out.print(author.getEmailAddress()); - out.print(">"); - out.println(); + out.println(MessageFormat.format(CLIText.get().authorInfo, author.getName(), author.getEmailAddress())); final TimeZone authorTZ = author.getTimeZone(); fmt.setTimeZone(authorTZ != null ? authorTZ : myTZ); - out.print("Date: "); - out.print(fmt.format(author.getWhen())); - out.println(); + out.println(MessageFormat.format(CLIText.get().dateInfo, fmt.format(author.getWhen()))); out.println(); final String[] lines = c.getFullMessage().split("\n"); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java index 44d1e754fe..e750e2dea8 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java @@ -53,10 +53,10 @@ import org.eclipse.jgit.transport.FetchConnection; import org.eclipse.jgit.transport.Transport; class LsRemote extends TextBuiltin { - @Option(name = "--timeout", metaVar = "SECONDS", usage = "abort connection if no activity") + @Option(name = "--timeout", metaVar = "metaVar_service", usage = "usage_abortConnectionIfNoActivity") int timeout = -1; - @Argument(index = 0, metaVar = "uri-ish", required = true) + @Argument(index = 0, metaVar = "metaVar_uriish", required = true) private String remote; @Override diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java index 1a28a9a48f..4b63edeb0d 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java @@ -53,10 +53,10 @@ import org.eclipse.jgit.treewalk.AbstractTreeIterator; import org.eclipse.jgit.treewalk.TreeWalk; class LsTree extends TextBuiltin { - @Option(name = "--recursive", usage = "recurse into subtrees", aliases = { "-r" }) + @Option(name = "--recursive", usage = "usage_recurseIntoSubtrees", aliases = { "-r" }) private boolean recursive; - @Argument(index = 0, required = true, metaVar = "tree-ish") + @Argument(index = 0, required = true, metaVar = "metaVar_treeish") private AbstractTreeIterator tree; @Override diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java index f1191a4599..306ac816d8 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java @@ -45,9 +45,11 @@ package org.eclipse.jgit.pgm; import java.io.File; +import java.io.PrintWriter; import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; import java.net.URL; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -70,19 +72,19 @@ import org.kohsuke.args4j.Option; /** Command line entry point. */ public class Main { - @Option(name = "--help", usage = "display this help text", aliases = { "-h" }) + @Option(name = "--help", usage = "usage_displayThisHelpText", aliases = { "-h" }) private boolean help; - @Option(name = "--show-stack-trace", usage = "display the Java stack trace on exceptions") + @Option(name = "--show-stack-trace", usage = "usage_displayThejavaStackTraceOnExceptions") private boolean showStackTrace; - @Option(name = "--git-dir", metaVar = "GIT_DIR", usage = "set the git repository to operate on") + @Option(name = "--git-dir", metaVar = "metaVar_gitDir", usage = "usage_setTheGitRepositoryToOperateOn") private File gitdir; - @Argument(index = 0, metaVar = "command", required = true, handler = SubcommandHandler.class) + @Argument(index = 0, metaVar = "metaVar_command", required = true, handler = SubcommandHandler.class) private TextBuiltin subcommand; - @Argument(index = 1, metaVar = "ARG") + @Argument(index = 1, metaVar = "metaVar_arg") private List<String> arguments = new ArrayList<String>(); /** @@ -101,17 +103,17 @@ public class Main { configureHttpProxy(); me.execute(argv); } catch (Die err) { - System.err.println("fatal: " + err.getMessage()); + System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage())); if (me.showStackTrace) err.printStackTrace(); System.exit(128); } catch (Exception err) { if (!me.showStackTrace && err.getCause() != null && err instanceof TransportException) - System.err.println("fatal: " + err.getCause().getMessage()); + System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getCause().getMessage())); if (err.getClass().getName().startsWith("org.eclipse.jgit.errors.")) { - System.err.println("fatal: " + err.getMessage()); + System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage())); if (me.showStackTrace) err.printStackTrace(); System.exit(128); @@ -123,25 +125,27 @@ public class Main { private void execute(final String[] argv) throws Exception { final CmdLineParser clp = new CmdLineParser(this); + PrintWriter writer = new PrintWriter(System.err); try { clp.parseArgument(argv); } catch (CmdLineException err) { if (argv.length > 0 && !help) { - System.err.println("fatal: " + err.getMessage()); + writer.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage())); + writer.flush(); System.exit(1); } } if (argv.length == 0 || help) { - final String ex = clp.printExample(ExampleMode.ALL); - System.err.println("jgit" + ex + " command [ARG ...]"); + final String ex = clp.printExample(ExampleMode.ALL, CLIText.get().resourceBundle()); + writer.println("jgit" + ex + " command [ARG ...]"); if (help) { - System.err.println(); - clp.printUsage(System.err); - System.err.println(); + writer.println(); + clp.printUsage(writer, CLIText.get().resourceBundle()); + writer.println(); } else if (subcommand == null) { - System.err.println(); - System.err.println("The most commonly used commands are:"); + writer.println(); + writer.println(CLIText.get().mostCommonlyUsedCommandsAre); final CommandRef[] common = CommandCatalog.common(); int width = 0; for (final CommandRef c : common) @@ -149,15 +153,16 @@ public class Main { width += 2; for (final CommandRef c : common) { - System.err.print(' '); - System.err.print(c.getName()); + writer.print(' '); + writer.print(c.getName()); for (int i = c.getName().length(); i < width; i++) - System.err.print(' '); - System.err.print(c.getUsage()); - System.err.println(); + writer.print(' '); + writer.print(CLIText.get().resourceBundle().getString(c.getUsage())); + writer.println(); } - System.err.println(); + writer.println(); } + writer.flush(); System.exit(1); } @@ -203,7 +208,8 @@ public class Main { altobjectdirs = null; if (gitdir == null || !gitdir.isDirectory()) { - System.err.println("error: can't find git directory"); + writer.println(CLIText.get().cantFindGitDirectory); + writer.flush(); System.exit(1); } cmd.init(new Repository(gitdir, gitworktree, objectdir, altobjectdirs, indexfile), gitdir); @@ -252,15 +258,15 @@ public class Main { return false; } catch (IllegalArgumentException e) { - throw new RuntimeException("Cannot setup console", e); + throw new RuntimeException(CLIText.get().cannotSetupConsole, e); } catch (SecurityException e) { - throw new RuntimeException("Cannot setup console", e); + throw new RuntimeException(CLIText.get().cannotSetupConsole, e); } catch (IllegalAccessException e) { - throw new RuntimeException("Cannot setup console", e); + throw new RuntimeException(CLIText.get().cannotSetupConsole, e); } catch (InvocationTargetException e) { - throw new RuntimeException("Cannot setup console", e); + throw new RuntimeException(CLIText.get().cannotSetupConsole, e); } catch (NoSuchMethodException e) { - throw new RuntimeException("Cannot setup console", e); + throw new RuntimeException(CLIText.get().cannotSetupConsole, e); } } @@ -297,8 +303,7 @@ public class Main { final URL u = new URL((s.indexOf("://") == -1) ? "http://" + s : s); if (!"http".equals(u.getProtocol())) - throw new MalformedURLException("Invalid http_proxy: " + s - + ": Only http supported."); + throw new MalformedURLException(MessageFormat.format(CLIText.get().invalidHttpProxyOnlyHttpSupported, s)); final String proxyHost = u.getHost(); final int proxyPort = u.getPort(); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/MergeBase.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/MergeBase.java index 91fd7443b0..f59fd43158 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/MergeBase.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/MergeBase.java @@ -53,15 +53,15 @@ import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.filter.RevFilter; class MergeBase extends TextBuiltin { - @Option(name = "--all", usage = "display all possible merge bases") + @Option(name = "--all", usage = "usage_displayAllPossibleMergeBases") private boolean all; - @Argument(index = 0, metaVar = "commit-ish", required = true) + @Argument(index = 0, metaVar = "metaVar_commitish", required = true) void commit_0(final RevCommit c) { commits.add(c); } - @Argument(index = 1, metaVar = "commit-ish", required = true) + @Argument(index = 1, metaVar = "metaVar_commitish", required = true) private final List<RevCommit> commits = new ArrayList<RevCommit>(); @Override diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java index 2c02545639..22fd7e38f5 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.pgm; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -59,15 +60,15 @@ import org.eclipse.jgit.transport.Transport; import org.eclipse.jgit.transport.URIish; import org.eclipse.jgit.transport.RemoteRefUpdate.Status; -@Command(common = true, usage = "Update remote repository from local refs") +@Command(common = true, usage = "usage_UpdateRemoteRepositoryFromLocalRefs") class Push extends TextBuiltin { - @Option(name = "--timeout", metaVar = "SECONDS", usage = "abort connection if no activity") + @Option(name = "--timeout", metaVar = "metaVar_seconds", usage = "usage_abortConnectionIfNoActivity") int timeout = -1; - @Argument(index = 0, metaVar = "uri-ish") + @Argument(index = 0, metaVar = "metaVar_uriish") private String remote = Constants.DEFAULT_REMOTE_NAME; - @Argument(index = 1, metaVar = "refspec") + @Argument(index = 1, metaVar = "metaVar_refspec") private final List<RefSpec> refSpecs = new ArrayList<RefSpec>(); @Option(name = "--all") @@ -94,7 +95,7 @@ class Push extends TextBuiltin { @Option(name = "--force", aliases = { "-f" }) private boolean force; - @Option(name = "--receive-pack", metaVar = "path") + @Option(name = "--receive-pack", metaVar = "metaVar_path") private String receivePack; @Option(name = "--dry-run") @@ -164,14 +165,14 @@ class Push extends TextBuiltin { AbstractFetchCommand.showRemoteMessages(result.getMessages()); if (everythingUpToDate) - out.println("Everything up-to-date"); + out.println(CLIText.get().everythingUpToDate); } private void printRefUpdateResult(final URIish uri, final PushResult result, final RemoteRefUpdate rru) { if (!shownURI) { shownURI = true; - out.format("To %s\n", uri); + out.println(MessageFormat.format(CLIText.get().pushTo, uri)); } final String remoteName = rru.getRemoteName(); @@ -197,7 +198,7 @@ class Push extends TextBuiltin { .name() + (fastForward ? ".." : "...") + rru.getNewObjectId().abbreviate(db).name(); - final String message = fastForward ? null : "forced update"; + final String message = fastForward ? null : CLIText.get().forcedUpdate; printUpdateLine(flag, summary, srcRef, remoteName, message); } } @@ -209,17 +210,18 @@ class Push extends TextBuiltin { case REJECTED_NODELETE: printUpdateLine('!', "[rejected]", null, remoteName, - "remote side does not support deleting refs"); + CLIText.get().remoteSideDoesNotSupportDeletingRefs); break; case REJECTED_NONFASTFORWARD: printUpdateLine('!', "[rejected]", srcRef, remoteName, - "non-fast forward"); + CLIText.get().nonFastForward); break; case REJECTED_REMOTE_CHANGED: - final String message = "remote ref object changed - is not expected one " - + rru.getExpectedOldObjectId().abbreviate(db).name(); + final String message = MessageFormat.format( + CLIText.get().remoteRefObjectChangedIsNotExpectedOne + , rru.getExpectedOldObjectId().abbreviate(db).name()); printUpdateLine('!', "[rejected]", srcRef, remoteName, message); break; diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java index f43a2793ee..09a9f2b580 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java @@ -45,14 +45,15 @@ package org.eclipse.jgit.pgm; import java.io.File; +import java.text.MessageFormat; import org.kohsuke.args4j.Argument; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Repository; -@Command(common = false, usage = "Server side backend for 'jgit push'") +@Command(common = false, usage = "usage_ServerSideBackendForJgitPush") class ReceivePack extends TextBuiltin { - @Argument(index = 0, required = true, metaVar = "DIRECTORY", usage = "Repository to receive into") + @Argument(index = 0, required = true, metaVar = "metaVar_directory", usage = "usage_RepositoryToReceiveInto") File dstGitdir; @Override @@ -68,7 +69,7 @@ class ReceivePack extends TextBuiltin { dstGitdir = new File(dstGitdir, Constants.DOT_GIT); db = new Repository(dstGitdir); if (!db.getObjectsDirectory().isDirectory()) - throw die("'" + dstGitdir.getPath() + "' not a git repository"); + throw die(MessageFormat.format(CLIText.get().notAGitRepository, dstGitdir.getPath())); rp = new org.eclipse.jgit.transport.ReceivePack(db); rp.receive(System.in, System.out, System.err); } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java index cb0cd6d0f5..ea6eeb102c 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.pgm; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.EnumSet; import java.util.List; @@ -109,10 +110,10 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { enableRevSort(RevSort.BOUNDARY, on); } - @Argument(index = 0, metaVar = "commit-ish") + @Argument(index = 0, metaVar = "metaVar_commitish") private final List<RevCommit> commits = new ArrayList<RevCommit>(); - @Option(name = "--", metaVar = "path", multiValued = true, handler = PathTreeFilterHandler.class) + @Option(name = "--", metaVar = "metaVar_path", multiValued = true, handler = PathTreeFilterHandler.class) private TreeFilter pathFilter = TreeFilter.ALL; private final List<RevFilter> revLimiter = new ArrayList<RevFilter>(); @@ -150,7 +151,7 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { if (commits.isEmpty()) { final ObjectId head = db.resolve(Constants.HEAD); if (head == null) - throw die("Cannot resolve " + Constants.HEAD); + throw die(MessageFormat.format(CLIText.get().cannotResolve, Constants.HEAD)); commits.add(walk.parseCommit(head)); } for (final RevCommit c : commits) { @@ -167,9 +168,8 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { final long end = System.currentTimeMillis(); System.err.print(n); System.err.print(' '); - System.err.print(end - start); - System.err.print(" ms"); - System.err.println(); + System.err.println(MessageFormat.format( + CLIText.get().timeInMilliSeconds, end - start)); } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java index 63e6e1712d..1b8711dc9d 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java @@ -57,9 +57,9 @@ import org.eclipse.jgit.pgm.opt.PathTreeFilterHandler; import org.eclipse.jgit.treewalk.TreeWalk; import org.eclipse.jgit.treewalk.filter.TreeFilter; -@Command(usage = "Stop tracking a file", common = true) +@Command(usage = "usage_StopTrackingAFile", common = true) class Rm extends TextBuiltin { - @Argument(metaVar = "path", usage = "path", multiValued = true, required = true, handler = PathTreeFilterHandler.class) + @Argument(metaVar = "metaVar_path", usage = "usage_path", multiValued = true, required = true, handler = PathTreeFilterHandler.class) @Option(name = "--", handler = StopOptionHandler.class) private TreeFilter paths; diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java index 703b10baf2..63d26eacae 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java @@ -47,6 +47,8 @@ package org.eclipse.jgit.pgm; +import java.text.MessageFormat; + import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option; import org.eclipse.jgit.errors.MissingObjectException; @@ -55,18 +57,18 @@ import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectLoader; import org.eclipse.jgit.lib.PersonIdent; -@Command(common = true, usage = "Create a tag") +@Command(common = true, usage = "usage_CreateATag") class Tag extends TextBuiltin { - @Option(name = "-f", usage = "force replacing an existing tag") + @Option(name = "-f", usage = "usage_forceReplacingAnExistingTag") private boolean force; - @Option(name = "-m", metaVar = "message", usage = "tag message") + @Option(name = "-m", metaVar = "metaVar_message", usage = "usage_tagMessage") private String message = ""; - @Argument(index = 0, required = true, metaVar = "name") + @Argument(index = 0, required = true, metaVar = "metaVar_name") private String tagName; - @Argument(index = 1, metaVar = "object") + @Argument(index = 1, metaVar = "metaVar_object") private ObjectId object; @Override @@ -74,15 +76,14 @@ class Tag extends TextBuiltin { if (object == null) { object = db.resolve(Constants.HEAD); if (object == null) - throw die("Cannot resolve " + Constants.HEAD); + throw die(MessageFormat.format(CLIText.get().cannotResolve, Constants.HEAD)); } if (!tagName.startsWith(Constants.R_TAGS)) tagName = Constants.R_TAGS + tagName; if (!force && db.resolve(tagName) != null) { - throw die("fatal: tag '" - + tagName.substring(Constants.R_TAGS.length()) - + "' exists"); + throw die(MessageFormat.format(CLIText.get().fatalErrorTagExists + , tagName.substring(Constants.R_TAGS.length()))); } final ObjectLoader ldr = db.openObject(object); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java index 13b45e242a..b6f12a1ab1 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java @@ -53,6 +53,8 @@ import java.io.File; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.text.MessageFormat; +import java.util.ResourceBundle; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.Option; @@ -75,7 +77,7 @@ import org.eclipse.jgit.revwalk.RevWalk; public abstract class TextBuiltin { private String commandName; - @Option(name = "--help", usage = "display this help text", aliases = { "-h" }) + @Option(name = "--help", usage = "usage_displayThisHelpText", aliases = { "-h" }) private boolean help; /** Stream to output to, typically this is standard output. */ @@ -110,7 +112,7 @@ public abstract class TextBuiltin { out = new PrintWriter(new BufferedWriter( new OutputStreamWriter(System.out))); } catch (IOException e) { - throw die("cannot create output stream"); + throw die(CLIText.get().cannotCreateOutputStream); } if (repo != null) { @@ -153,7 +155,7 @@ public abstract class TextBuiltin { clp.parseArgument(args); } catch (CmdLineException err) { if (!help) { - System.err.println("fatal: " + err.getMessage()); + System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage())); System.exit(1); } } @@ -181,20 +183,30 @@ public abstract class TextBuiltin { * @param clp */ public void printUsageAndExit(final String message, final CmdLineParser clp) { - System.err.println(message); - System.err.print("jgit "); - System.err.print(commandName); - clp.printSingleLineUsage(System.err); - System.err.println(); + PrintWriter writer = new PrintWriter(System.err); + writer.println(message); + writer.print("jgit "); + writer.print(commandName); + clp.printSingleLineUsage(writer, getResourceBundle()); + writer.println(); - System.err.println(); - clp.printUsage(System.err); - System.err.println(); + writer.println(); + clp.printUsage(writer, getResourceBundle()); + writer.println(); + writer.flush(); System.exit(1); } /** + * @return the resource bundle that will be passed to args4j for purpose + * of string localization + */ + protected ResourceBundle getResourceBundle() { + return CLIText.get().resourceBundle(); + } + + /** * Perform the actions of this command. * <p> * This method should only be invoked by {@link #execute(String[])}. @@ -216,7 +228,7 @@ public abstract class TextBuiltin { ObjectId resolve(final String s) throws IOException { final ObjectId r = db.resolve(s); if (r == null) - throw die("Not a revision: " + s); + throw die(MessageFormat.format(CLIText.get().notARevision, s)); return r; } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java index ea30899dcb..52d2488f70 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java @@ -45,18 +45,19 @@ package org.eclipse.jgit.pgm; import java.io.File; +import java.text.MessageFormat; import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Repository; -@Command(common = false, usage = "Server side backend for 'jgit fetch'") +@Command(common = false, usage = "usage_ServerSideBackendForJgitFetch") class UploadPack extends TextBuiltin { - @Option(name = "--timeout", metaVar = "SECONDS", usage = "abort connection if no activity") + @Option(name = "--timeout", metaVar = "metaVar_seconds", usage = "usage_abortConnectionIfNoActivity") int timeout = -1; - @Argument(index = 0, required = true, metaVar = "DIRECTORY", usage = "Repository to read from") + @Argument(index = 0, required = true, metaVar = "metaVar_directory", usage = "usage_RepositoryToReadFrom") File srcGitdir; @Override @@ -72,7 +73,7 @@ class UploadPack extends TextBuiltin { srcGitdir = new File(srcGitdir, Constants.DOT_GIT); db = new Repository(srcGitdir); if (!db.getObjectsDirectory().isDirectory()) - throw die("'" + srcGitdir.getPath() + "' not a git repository"); + throw die(MessageFormat.format(CLIText.get().notAGitRepository, srcGitdir.getPath())); rp = new org.eclipse.jgit.transport.UploadPack(db); if (0 <= timeout) rp.setTimeout(timeout); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Version.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Version.java index 11b6e83523..5bad4ef98c 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Version.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Version.java @@ -43,16 +43,16 @@ package org.eclipse.jgit.pgm; -@Command(common = true, usage = "Display the version of jgit") +import java.text.MessageFormat; + +@Command(common = true, usage = "usage_DisplayTheVersionOfJgit") class Version extends TextBuiltin { @Override protected void run() throws Exception { final Package pkg = getClass().getPackage(); if (pkg == null || pkg.getImplementationVersion() == null) - throw die("Cannot read package information."); + throw die(CLIText.get().cannotReadPackageInformation); - out.print("jgit version "); - out.print(pkg.getImplementationVersion()); - out.println(); + out.println(MessageFormat.format(CLIText.get().jgitVersion, pkg.getImplementationVersion())); } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java index 8949cbce6d..d772ffe23f 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java @@ -44,8 +44,11 @@ package org.eclipse.jgit.pgm.debug; +import java.text.MessageFormat; + import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheTree; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.TextBuiltin; class MakeCacheTree extends TextBuiltin { @@ -57,16 +60,8 @@ class MakeCacheTree extends TextBuiltin { } private void show(final DirCacheTree tree) { - out.print("\""); - out.print(tree.getPathString()); - out.print("\""); - out.print(": "); - out.print(tree.getEntrySpan()); - out.print(" entries"); - out.print(", "); - out.print(tree.getChildCount()); - out.print(" children"); - out.println(); + out.println(MessageFormat.format(CLIText.get().cacheTreePathInfo + , tree.getPathString(), tree.getEntrySpan(), tree.getChildCount())); for (int i = 0; i < tree.getChildCount(); i++) show(tree.getChild(i)); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ReadDirCache.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ReadDirCache.java index b0c1c77fdb..2a1079b313 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ReadDirCache.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ReadDirCache.java @@ -44,7 +44,10 @@ package org.eclipse.jgit.pgm.debug; +import java.text.MessageFormat; + import org.eclipse.jgit.dircache.DirCache; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.TextBuiltin; class ReadDirCache extends TextBuiltin { @@ -55,6 +58,7 @@ class ReadDirCache extends TextBuiltin { for (int i = 0; i < cnt; i++) DirCache.read(db); final long end = System.currentTimeMillis(); - out.println(" average " + ((end - start) / cnt) + " ms/read"); + out.print(" "); + out.println(MessageFormat.format(CLIText.get().averageMSPerRead, (end - start) / cnt)); } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java index 0a5f2a0c9a..38df041017 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java @@ -48,6 +48,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -72,6 +73,7 @@ import org.eclipse.jgit.lib.RefUpdate; import org.eclipse.jgit.lib.RefWriter; import org.eclipse.jgit.lib.TextProgressMonitor; import org.eclipse.jgit.lib.Tree; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.TextBuiltin; import org.eclipse.jgit.revwalk.RevWalk; @@ -96,13 +98,13 @@ import org.eclipse.jgit.revwalk.RevWalk; class RebuildCommitGraph extends TextBuiltin { private final String REALLY = "--destroy-this-repository"; - @Option(name = REALLY, usage = "approve destruction of repository") + @Option(name = REALLY, usage = "usage_approveDestructionOfRepository") boolean really; - @Argument(index = 0, required = true, metaVar = "REFS", usage = "for-each-ref output") + @Argument(index = 0, required = true, metaVar = "metaVar_refs", usage = "usage_forEachRefOutput") File refList; - @Argument(index = 1, required = true, metaVar = "DAG", usage = "log --all '--pretty=format:%H %ct %P' output") + @Argument(index = 1, required = true, metaVar = "metaVar_refs", usage = "usage_logAllPretty") File graph; private final ProgressMonitor pm = new TextProgressMonitor(); @@ -112,28 +114,15 @@ class RebuildCommitGraph extends TextBuiltin { @Override protected void run() throws Exception { if (!really && !db.getAllRefs().isEmpty()) { - final StringBuilder m = new StringBuilder(); - m.append("fatal: "); - m.append("This program will destroy the repository:"); - m.append("\n"); - m.append("fatal:\n"); - m.append("fatal: "); - m.append(db.getDirectory().getAbsolutePath()); - m.append("\n"); - m.append("fatal:\n"); - m.append("fatal: "); - m.append("To continue, add "); - m.append(REALLY); - m.append(" to the command line"); - m.append("\n"); - m.append("fatal:"); - System.err.println(m); - throw die("Need approval to destroy current repository"); + System.err.println( + MessageFormat.format(CLIText.get().fatalThisProgramWillDestroyTheRepository + , db.getDirectory().getAbsolutePath(), REALLY)); + throw die(CLIText.get().needApprovalToDestroyCurrentRepository); } if (!refList.isFile()) - throw die("no such file: " + refList.getPath()); + throw die(MessageFormat.format(CLIText.get().noSuchFile, refList.getPath())); if (!graph.isFile()) - throw die("no such file: " + graph.getPath()); + throw die(MessageFormat.format(CLIText.get().noSuchFile, graph.getPath())); recreateCommitGraph(); detachHead(); @@ -240,10 +229,10 @@ class RebuildCommitGraph extends TextBuiltin { final LockFile lf; lf = new LockFile(new File(db.getDirectory(), Constants.HEAD)); if (!lf.lock()) - throw new IOException("Cannot lock HEAD"); + throw new IOException(MessageFormat.format(CLIText.get().cannotLock, Constants.HEAD)); lf.write(id); if (!lf.commit()) - throw new IOException("Cannot deatch HEAD"); + throw new IOException(CLIText.get().cannotDeatchHEAD); } } @@ -267,14 +256,14 @@ class RebuildCommitGraph extends TextBuiltin { final File file = new File(db.getDirectory(), name); final LockFile lck = new LockFile(file); if (!lck.lock()) - throw new ObjectWritingException("Can't write " + file); + throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite, file)); try { lck.write(content); } catch (IOException ioe) { - throw new ObjectWritingException("Can't write " + file); + throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite, file)); } if (!lck.commit()) - throw new ObjectWritingException("Can't write " + file); + throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite, file)); } }.writePackedRefs(); } @@ -299,7 +288,7 @@ class RebuildCommitGraph extends TextBuiltin { rw.parseAny(id); } catch (MissingObjectException mue) { if (!Constants.TYPE_COMMIT.equals(type)) { - System.err.println("skipping " + type + " " + name); + System.err.println(MessageFormat.format(CLIText.get().skippingObject, type, name)); continue; } throw new MissingObjectException(id, type); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java index 29cdc98a83..09796edb30 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java @@ -44,8 +44,11 @@ package org.eclipse.jgit.pgm.debug; +import java.text.MessageFormat; + import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheTree; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.TextBuiltin; class ShowCacheTree extends TextBuiltin { @@ -54,21 +57,13 @@ class ShowCacheTree extends TextBuiltin { final DirCache cache = DirCache.read(db); final DirCacheTree tree = cache.getCacheTree(false); if (tree == null) - throw die("no 'TREE' section in index"); + throw die(CLIText.get().noTREESectionInIndex); show(tree); } private void show(final DirCacheTree tree) { - out.print("\""); - out.print(tree.getPathString()); - out.print("\""); - out.print(": "); - out.print(tree.getEntrySpan()); - out.print(" entries"); - out.print(", "); - out.print(tree.getChildCount()); - out.print(" children"); - out.println(); + out.println(MessageFormat.format(CLIText.get().cacheTreePathInfo + , tree.getPathString(), tree.getEntrySpan(), tree.getChildCount())); for (int i = 0; i < tree.getChildCount(); i++) show(tree.getChild(i)); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java index 063cab5acf..78fc1453d1 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java @@ -46,14 +46,15 @@ package org.eclipse.jgit.pgm.debug; import java.net.URL; import org.kohsuke.args4j.Option; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.Command; import org.eclipse.jgit.pgm.CommandCatalog; import org.eclipse.jgit.pgm.CommandRef; import org.eclipse.jgit.pgm.TextBuiltin; -@Command(usage = "Display a list of all registered jgit commands") +@Command(usage = "usage_displayAListOfAllRegisteredJgitCommands") class ShowCommands extends TextBuiltin { - @Option(name = "--pretty", usage = "alter the detail shown") + @Option(name = "--pretty", usage = "usage_alterTheDetailShown") private Format pretty = Format.USAGE; @Override @@ -83,7 +84,9 @@ class ShowCommands extends TextBuiltin { /** */ USAGE { void print(final CommandRef c) { - System.err.print(c.getUsage()); + String usage = c.getUsage(); + if (usage != null && usage.length() > 0) + System.err.print(CLIText.get().resourceBundle().getString(usage)); } }, @@ -104,7 +107,7 @@ class ShowCommands extends TextBuiltin { final URL url = ldr.getResource(cn); if (url == null) { - System.err.print("!! NOT FOUND !!"); + System.err.print(CLIText.get().notFound); return; } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteDirCache.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteDirCache.java index 54301dd041..cee5966a03 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteDirCache.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteDirCache.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.pgm.debug; import org.eclipse.jgit.dircache.DirCache; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.TextBuiltin; class WriteDirCache extends TextBuiltin { @@ -52,10 +53,10 @@ class WriteDirCache extends TextBuiltin { protected void run() throws Exception { final DirCache cache = DirCache.read(db); if (!cache.lock()) - throw die("failed to lock index"); + throw die(CLIText.get().failedToLockIndex); cache.read(); cache.write(); if (!cache.commit()) - throw die("failed to commit index"); + throw die(CLIText.get().failedToCommitIndex); } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Iplog.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Iplog.java index bb51f56070..e13bb1f136 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Iplog.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Iplog.java @@ -46,12 +46,14 @@ package org.eclipse.jgit.pgm.eclipse; import java.io.File; import java.io.OutputStream; import java.net.CookieHandler; +import java.text.MessageFormat; import org.eclipse.jgit.iplog.IpLogGenerator; import org.eclipse.jgit.iplog.SimpleCookieManager; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.LockFile; import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.Command; import org.eclipse.jgit.pgm.TextBuiltin; import org.eclipse.jgit.revwalk.RevObject; @@ -60,15 +62,15 @@ import org.eclipse.jgit.revwalk.RevWalk; import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option; -@Command(name = "eclipse-iplog", common = false, usage = "Produce an Eclipse IP log") +@Command(name = "eclipse-iplog", common = false, usage = "usage_produceAnEclipseIPLog") class Iplog extends TextBuiltin { - @Option(name = "--version", aliases = { "-r" }, metaVar = "VERSION", usage = "Symbolic version for the project") + @Option(name = "--version", aliases = { "-r" }, metaVar = "metaVar_version", usage = "usage_symbolicVersionForTheProject") private String version; - @Option(name = "--output", aliases = { "-o" }, metaVar = "FILE", usage = "Output file") + @Option(name = "--output", aliases = { "-o" }, metaVar = "metaVar_file", usage = "usage_outputFile") private File output; - @Argument(index = 0, metaVar = "COMMIT|TAG") + @Argument(index = 0, metaVar = "metaVar_commitOrTag") private ObjectId commitId; @Override @@ -79,8 +81,8 @@ class Iplog extends TextBuiltin { final IpLogGenerator log = new IpLogGenerator(); if (commitId == null) { - System.err.println("warning: No commit given on command line," - + " assuming " + Constants.HEAD); + System.err.println(MessageFormat.format( + CLIText.get().warningNoCommitGivenOnCommandLine, Constants.HEAD)); commitId = db.resolve(Constants.HEAD); } @@ -89,7 +91,7 @@ class Iplog extends TextBuiltin { if (version == null && start instanceof RevTag) version = ((RevTag) start).getTagName(); else if (version == null) - throw die(start.name() + " is not a tag, --version is required"); + throw die(MessageFormat.format(CLIText.get().notATagVersionIsRequired, start.name())); log.scan(db, rw.parseCommit(start), version); @@ -98,7 +100,7 @@ class Iplog extends TextBuiltin { output.getParentFile().mkdirs(); LockFile lf = new LockFile(output); if (!lf.lock()) - throw die("Cannot lock " + output); + throw die(MessageFormat.format(CLIText.get().cannotLock, output)); try { OutputStream os = lf.getOutputStream(); try { @@ -107,7 +109,7 @@ class Iplog extends TextBuiltin { os.close(); } if (!lf.commit()) - throw die("Cannot write " + output); + throw die(MessageFormat.format(CLIText.get().cannotWrite, output)); } finally { lf.unlock(); } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Ipzilla.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Ipzilla.java index 616ca420cb..4f0e338e8d 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Ipzilla.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/eclipse/Ipzilla.java @@ -51,22 +51,23 @@ import java.net.URL; import org.eclipse.jgit.iplog.IpLogMeta; import org.eclipse.jgit.iplog.SimpleCookieManager; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.Command; import org.eclipse.jgit.pgm.TextBuiltin; import org.kohsuke.args4j.Option; -@Command(name = "eclipse-ipzilla", common = false, usage = "Synchronize IPZilla data") +@Command(name = "eclipse-ipzilla", common = false, usage = "usage_synchronizeIPZillaData") class Ipzilla extends TextBuiltin { - @Option(name = "--url", metaVar = "URL", usage = "IPZilla URL") + @Option(name = "--url", metaVar = "metaVar_url", usage = "usage_IPZillaURL") private String url = "https://dev.eclipse.org/ipzilla/"; - @Option(name = "--username", metaVar = "USER", usage = "IPZilla Username") + @Option(name = "--username", metaVar = "metaVar_user", usage = "usage_IPZillaUsername") private String username; - @Option(name = "--password", metaVar = "PASS", usage = "IPZilla Password") + @Option(name = "--password", metaVar = "metaVar_pass", usage = "usage_IPZillaPassword") private String password; - @Option(name = "--file", aliases = { "-f" }, metaVar = "FILE", usage = "Input/output file") + @Option(name = "--file", aliases = { "-f" }, metaVar = "metaVar_file", usage = "usage_inputOutputFile") private File output; @Override @@ -81,7 +82,7 @@ class Ipzilla extends TextBuiltin { null, // ipzilla.getPort(), // ipzilla.getProtocol(), // - "IPZilla Password", // + CLIText.get().IPZillaPasswordPrompt, // ipzilla.getProtocol(), // ipzilla, // Authenticator.RequestorType.SERVER); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java index c31676d72f..0bc9ee1122 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java @@ -46,6 +46,7 @@ package org.eclipse.jgit.pgm.opt; import java.io.File; import java.io.IOException; +import java.text.MessageFormat; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineParser; @@ -59,6 +60,7 @@ import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.WindowCursor; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.treewalk.AbstractTreeIterator; import org.eclipse.jgit.treewalk.CanonicalTreeParser; import org.eclipse.jgit.treewalk.FileTreeIterator; @@ -102,7 +104,7 @@ public class AbstractTreeIteratorHandler extends try { dirc = DirCache.read(new File(name)); } catch (IOException e) { - throw new CmdLineException(name + " is not an index file", e); + throw new CmdLineException(MessageFormat.format(CLIText.get().notAnIndexFile, name), e); } setter.addValue(new DirCacheIterator(dirc)); return 1; @@ -115,19 +117,18 @@ public class AbstractTreeIteratorHandler extends throw new CmdLineException(e.getMessage()); } if (id == null) - throw new CmdLineException(name + " is not a tree"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); final CanonicalTreeParser p = new CanonicalTreeParser(); final WindowCursor curs = new WindowCursor(); try { p.reset(clp.getRepository(), clp.getRevWalk().parseTree(id), curs); } catch (MissingObjectException e) { - throw new CmdLineException(name + " is not a tree"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); } catch (IncorrectObjectTypeException e) { - throw new CmdLineException(name + " is not a tree"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); } catch (IOException e) { - throw new CmdLineException("cannot read " + name + ": " - + e.getMessage()); + throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); } finally { curs.release(); } @@ -138,6 +139,6 @@ public class AbstractTreeIteratorHandler extends @Override public String getDefaultMetaVariable() { - return "tree-ish"; + return CLIText.get().metaVar_treeish; } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java index a126fb1d85..7e61fb0418 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java @@ -51,6 +51,7 @@ import org.kohsuke.args4j.IllegalAnnotationError; import org.kohsuke.args4j.Option; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.TextBuiltin; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevTree; @@ -149,7 +150,7 @@ public class CmdLineParser extends org.kohsuke.args4j.CmdLineParser { */ public Repository getRepository() { if (db == null) - throw new IllegalStateException("No Git repository configured."); + throw new IllegalStateException(CLIText.get().noGitRepositoryConfigured); return db; } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/ObjectIdHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/ObjectIdHandler.java index d3f460c89d..f6550a5d88 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/ObjectIdHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/ObjectIdHandler.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.pgm.opt; import java.io.IOException; +import java.text.MessageFormat; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineParser; @@ -53,6 +54,7 @@ import org.kohsuke.args4j.spi.OptionHandler; import org.kohsuke.args4j.spi.Parameters; import org.kohsuke.args4j.spi.Setter; import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.pgm.CLIText; /** * Custom argument handler {@link ObjectId} from string values. @@ -91,11 +93,11 @@ public class ObjectIdHandler extends OptionHandler<ObjectId> { return 1; } - throw new CmdLineException(name + " is not an object"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notAnObject, name)); } @Override public String getDefaultMetaVariable() { - return "object"; + return CLIText.get().metaVar_object; } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/PathTreeFilterHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/PathTreeFilterHandler.java index bebf3d9a7d..50ff02aca9 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/PathTreeFilterHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/PathTreeFilterHandler.java @@ -53,6 +53,7 @@ import org.kohsuke.args4j.OptionDef; import org.kohsuke.args4j.spi.OptionHandler; import org.kohsuke.args4j.spi.Parameters; import org.kohsuke.args4j.spi.Setter; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.treewalk.filter.PathFilter; import org.eclipse.jgit.treewalk.filter.PathFilterGroup; import org.eclipse.jgit.treewalk.filter.TreeFilter; @@ -103,6 +104,6 @@ public class PathTreeFilterHandler extends OptionHandler<TreeFilter> { @Override public String getDefaultMetaVariable() { - return "path ..."; + return CLIText.get().metaVar_paths; } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RefSpecHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RefSpecHandler.java index 133c5f8db8..43b727ac02 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RefSpecHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RefSpecHandler.java @@ -49,6 +49,7 @@ import org.kohsuke.args4j.OptionDef; import org.kohsuke.args4j.spi.OptionHandler; import org.kohsuke.args4j.spi.Parameters; import org.kohsuke.args4j.spi.Setter; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.transport.RefSpec; /** @@ -79,6 +80,6 @@ public class RefSpecHandler extends OptionHandler<RefSpec> { @Override public String getDefaultMetaVariable() { - return "refspec"; + return CLIText.get().metaVar_refspec; } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java index 01caaf2018..bf1753634c 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.pgm.opt; import java.io.IOException; +import java.text.MessageFormat; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineParser; @@ -55,6 +56,7 @@ import org.kohsuke.args4j.spi.Setter; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevFlag; @@ -94,8 +96,8 @@ public class RevCommitHandler extends OptionHandler<RevCommit> { final int dot2 = name.indexOf(".."); if (dot2 != -1) { if (!option.isMultiValued()) - throw new CmdLineException("Only one " + option.metaVar() - + " expected in " + name + "." + ""); + throw new CmdLineException(MessageFormat.format(CLIText.get().onlyOneMetaVarExpectedIn + , option.metaVar(), name)); final String left = name.substring(0, dot2); final String right = name.substring(dot2 + 2); @@ -117,18 +119,17 @@ public class RevCommitHandler extends OptionHandler<RevCommit> { throw new CmdLineException(e.getMessage()); } if (id == null) - throw new CmdLineException(name + " is not a commit"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name)); final RevCommit c; try { c = clp.getRevWalk().parseCommit(id); } catch (MissingObjectException e) { - throw new CmdLineException(name + " is not a commit"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name)); } catch (IncorrectObjectTypeException e) { - throw new CmdLineException(name + " is not a commit"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name)); } catch (IOException e) { - throw new CmdLineException("cannot read " + name + ": " - + e.getMessage()); + throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); } if (interesting) @@ -141,6 +142,6 @@ public class RevCommitHandler extends OptionHandler<RevCommit> { @Override public String getDefaultMetaVariable() { - return "commit-ish"; + return CLIText.get().metaVar_commitish; } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java index c564b9b011..0b607ee06f 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.pgm.opt; import java.io.IOException; +import java.text.MessageFormat; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineParser; @@ -55,6 +56,7 @@ import org.kohsuke.args4j.spi.Setter; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.revwalk.RevTree; /** @@ -90,18 +92,17 @@ public class RevTreeHandler extends OptionHandler<RevTree> { throw new CmdLineException(e.getMessage()); } if (id == null) - throw new CmdLineException(name + " is not a tree"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); final RevTree c; try { c = clp.getRevWalk().parseTree(id); } catch (MissingObjectException e) { - throw new CmdLineException(name + " is not a tree"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); } catch (IncorrectObjectTypeException e) { - throw new CmdLineException(name + " is not a tree"); + throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); } catch (IOException e) { - throw new CmdLineException("cannot read " + name + ": " - + e.getMessage()); + throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); } setter.addValue(c); return 1; @@ -109,6 +110,6 @@ public class RevTreeHandler extends OptionHandler<RevTree> { @Override public String getDefaultMetaVariable() { - return "tree-ish"; + return CLIText.get().metaVar_treeish; } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/SubcommandHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/SubcommandHandler.java index 3378f38c19..35ed22bd30 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/SubcommandHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/SubcommandHandler.java @@ -51,6 +51,7 @@ import org.kohsuke.args4j.OptionDef; import org.kohsuke.args4j.spi.OptionHandler; import org.kohsuke.args4j.spi.Parameters; import org.kohsuke.args4j.spi.Setter; +import org.eclipse.jgit.pgm.CLIText; import org.eclipse.jgit.pgm.CommandCatalog; import org.eclipse.jgit.pgm.CommandRef; import org.eclipse.jgit.pgm.TextBuiltin; @@ -82,7 +83,7 @@ public class SubcommandHandler extends OptionHandler<TextBuiltin> { final CommandRef cr = CommandCatalog.get(name); if (cr == null) throw new CmdLineException(MessageFormat.format( - "{0} is not a jgit command", name)); + CLIText.get().notAJgitCommand, name)); // Force option parsing to stop. Everything after us should // be arguments known only to this command and must not be @@ -95,6 +96,6 @@ public class SubcommandHandler extends OptionHandler<TextBuiltin> { @Override public String getDefaultMetaVariable() { - return "command"; + return CLIText.get().metaVar_command; } } |