diff options
author | James Moger <james.moger@gitblit.com> | 2014-03-12 20:12:50 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-03-27 09:39:25 -0400 |
commit | 50380b329e69c0a9fa423475aee59a2c9633db69 (patch) | |
tree | cfc747afe4d6d49d1618c929ffe3e629f194dded /src/main/java/com/gitblit/AddIndexedBranch.java | |
parent | 03a03105bc613cf8b87aa67938e9c940197ef511 (diff) | |
download | gitblit-50380b329e69c0a9fa423475aee59a2c9633db69.tar.gz gitblit-50380b329e69c0a9fa423475aee59a2c9633db69.zip |
Replace JCommander with args4j
Diffstat (limited to 'src/main/java/com/gitblit/AddIndexedBranch.java')
-rw-r--r-- | src/main/java/com/gitblit/AddIndexedBranch.java | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/main/java/com/gitblit/AddIndexedBranch.java b/src/main/java/com/gitblit/AddIndexedBranch.java index 4b668c4e..459e1f00 100644 --- a/src/main/java/com/gitblit/AddIndexedBranch.java +++ b/src/main/java/com/gitblit/AddIndexedBranch.java @@ -28,11 +28,10 @@ import org.eclipse.jgit.lib.RepositoryCache.FileKey; import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.util.FS;
+import org.kohsuke.args4j.CmdLineException;
+import org.kohsuke.args4j.CmdLineParser;
+import org.kohsuke.args4j.Option;
-import com.beust.jcommander.JCommander;
-import com.beust.jcommander.Parameter;
-import com.beust.jcommander.ParameterException;
-import com.beust.jcommander.Parameters;
import com.gitblit.models.RefModel;
import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.JGitUtils;
@@ -48,12 +47,12 @@ public class AddIndexedBranch { public static void main(String... args) {
Params params = new Params();
- JCommander jc = new JCommander(params);
+ CmdLineParser parser = new CmdLineParser(params);
try {
- jc.parse(args);
- } catch (ParameterException t) {
+ parser.parseArgument(args);
+ } catch (CmdLineException t) {
System.err.println(t.getMessage());
- jc.usage();
+ parser.printUsage(System.out);
return;
}
@@ -95,7 +94,7 @@ public class AddIndexedBranch { Set<String> indexedBranches = new LinkedHashSet<String>();
// add all local branches to index
- if(params.addAllLocalBranches) {
+ if (params.addAllLocalBranches) {
List<RefModel> list = JGitUtils.getLocalBranches(repository, true, -1);
for (RefModel refModel : list) {
System.out.println(MessageFormat.format("adding [gitblit] indexBranch={0} for {1}", refModel.getName(), repo));
@@ -129,21 +128,20 @@ public class AddIndexedBranch { /**
- * JCommander Parameters class for AddIndexedBranch.
+ * Parameters class for AddIndexedBranch.
*/
- @Parameters(separators = " ")
private static class Params {
- @Parameter(names = { "--repositoriesFolder" }, description = "The root repositories folder ", required = true)
+ @Option(name = "--repositoriesFolder", usage = "The root repositories folder ", required = true, metaVar = "PATH")
public String folder;
- @Parameter(names = { "--branch" }, description = "The branch to index", required = false)
+ @Option(name = "--branch", usage = "The branch to index", metaVar = "BRANCH")
public String branch = "default";
- @Parameter(names = { "--skip" }, description = "Skip the named repository (simple fizzy matching is supported)", required = false)
+ @Option(name = "--skip", usage = "Skip the named repository (simple fizzy matching is supported)")
public List<String> exclusions = new ArrayList<String>();
- @Parameter(names = { "--all-local-branches" }, description = "Add all local branches to index. If specified, the --branch parameter is not considered.", required = false)
- public boolean addAllLocalBranches = false;
+ @Option(name = "--all-local-branches", usage = "Add all local branches to index. If specified, the --branch parameter is not considered.")
+ public boolean addAllLocalBranches;
}
}
|