summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2011-06-20 00:55:13 +0200
committerRobin Rosenberg <robin.rosenberg@dewire.com>2011-06-20 00:55:13 +0200
commit529a348961c59413fde0a489ee5118b77f923af0 (patch)
tree058dcbf5b607b18206706b238e128e4ee3b43f7b /org.eclipse.jgit.pgm
parent929862f322cf7ca4c13f9515d611a21e2680e2ba (diff)
downloadjgit-529a348961c59413fde0a489ee5118b77f923af0.tar.gz
jgit-529a348961c59413fde0a489ee5118b77f923af0.zip
RFC: Ugly fix for i18n of metaVar CLI arguments
This patch possibly ties to a specific version of args4j. Bug: 318286 Change-Id: I05d4ecf6bd25deec7fb2efbfa61913f4ec4e04e5 Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java31
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java36
2 files changed, 67 insertions, 0 deletions
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
index cf57f20b7b..d82ff499f9 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java
@@ -113,12 +113,43 @@ public class CLIText extends TranslationBundle {
/***/ public String mergeConflict;
/***/ public String mergeFailed;
/***/ public String mergeMadeBy;
+ /***/ public String metaVar_KEY;
+ /***/ public String metaVar_arg;
+ /***/ public String metaVar_author;
+ /***/ public String metaVar_bucket;
/***/ public String metaVar_command;
+ /***/ public String metaVar_commandDetail;
+ /***/ public String metaVar_commitOrTag;
+ /***/ public String metaVar_commitPaths;
/***/ public String metaVar_commitish;
+ /***/ public String metaVar_configFile;
+ /***/ public String metaVar_connProp;
+ /***/ public String metaVar_diffAlg;
+ /***/ public String metaVar_directory;
+ /***/ public String metaVar_file;
+ /***/ public String metaVar_gitDir;
+ /***/ public String metaVar_hostName;
+ /***/ public String metaVar_linesOfContext;
+ /***/ public String metaVar_message;
+ /***/ public String metaVar_n;
+ /***/ public String metaVar_name;
/***/ public String metaVar_object;
+ /***/ public String metaVar_op;
+ /***/ public String metaVar_pass;
+ /***/ public String metaVar_path;
/***/ public String metaVar_paths;
+ /***/ public String metaVar_port;
+ /***/ public String metaVar_ref;
+ /***/ public String metaVar_refs;
/***/ public String metaVar_refspec;
+ /***/ public String metaVar_remoteName;
+ /***/ public String metaVar_seconds;
+ /***/ public String metaVar_service;
/***/ public String metaVar_treeish;
+ /***/ public String metaVar_uriish;
+ /***/ public String metaVar_url;
+ /***/ public String metaVar_user;
+ /***/ public String metaVar_version;
/***/ public String mostCommonlyUsedCommandsAre;
/***/ public String needApprovalToDestroyCurrentRepository;
/***/ public String noGitRepositoryConfigured;
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 7e61fb0418..b14130f4aa 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
@@ -43,12 +43,17 @@
package org.eclipse.jgit.pgm.opt;
+import java.lang.reflect.Field;
import java.util.ArrayList;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.IllegalAnnotationError;
+import org.kohsuke.args4j.NamedOptionDef;
import org.kohsuke.args4j.Option;
+import org.kohsuke.args4j.OptionDef;
+import org.kohsuke.args4j.spi.OptionHandler;
+import org.kohsuke.args4j.spi.Setter;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.pgm.CLIText;
@@ -175,4 +180,35 @@ public class CmdLineParser extends org.kohsuke.args4j.CmdLineParser {
public RevWalk getRevWalkGently() {
return walk;
}
+
+ static class MyOptionDef extends OptionDef {
+
+ public MyOptionDef(OptionDef o) {
+ super(o.usage(), o.metaVar(), o.required(), o.handler(), o
+ .isMultiValued());
+ }
+
+ @Override
+ public String toString() {
+ if (metaVar() == null)
+ return "ARG";
+ try {
+ Field field = CLIText.class.getField(metaVar());
+ String ret = field.get(CLIText.get()).toString();
+ return ret;
+ } catch (Exception e) {
+ e.printStackTrace(System.err);
+ return metaVar();
+ }
+ }
+ }
+
+ @Override
+ protected OptionHandler createOptionHandler(OptionDef o, Setter setter) {
+ if (o instanceof NamedOptionDef)
+ return super.createOptionHandler(o, setter);
+ else
+ return super.createOptionHandler(new MyOptionDef(o), setter);
+
+ }
}