From 3ba8c505b3198f376981477e257a13b98b30152e Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 17 Jul 2008 21:44:12 -0400 Subject: [PATCH] Convert fetch program to args4j Signed-off-by: Shawn O. Pearce Signed-off-by: Robin Rosenberg --- .../src/org/spearce/jgit/pgm/Fetch.java | 27 ++++++++-------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Fetch.java b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Fetch.java index e5a0dce6..194f6693 100644 --- a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Fetch.java +++ b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Fetch.java @@ -37,9 +37,9 @@ package org.spearce.jgit.pgm; -import java.util.ArrayList; import java.util.List; +import org.kohsuke.args4j.Argument; import org.spearce.jgit.lib.RefUpdate; import org.spearce.jgit.lib.TextProgressMonitor; import org.spearce.jgit.transport.FetchResult; @@ -48,26 +48,17 @@ import org.spearce.jgit.transport.TrackingRefUpdate; import org.spearce.jgit.transport.Transport; class Fetch extends TextBuiltin { - @Override - public void execute(String[] args) throws Exception { - int argi = 0; - for (; argi < args.length; argi++) { - final String a = args[argi]; - if ("--".equals(a)) { - argi++; - break; - } else - break; - } - if (args.length == 0) - args = new String[] { "origin" }; + @Argument(index = 0, metaVar = "uri-ish") + private String remote = "origin"; - final Transport tn = Transport.open(db, args[argi++]); + @Argument(index = 1, metaVar = "refspec") + private List toget; + + @Override + protected void run() throws Exception { + final Transport tn = Transport.open(db, remote); final FetchResult r; try { - final List toget = new ArrayList(); - for (; argi < args.length; argi++) - toget.add(new RefSpec(args[argi])); r = tn.fetch(new TextProgressMonitor(), toget); if (r.getTrackingRefUpdates().isEmpty()) return; -- 2.11.4.GIT