diff options
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java | 31 | ||||
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java | 36 |
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); + + } } |