[EGIT PATCH 1/3] Include a print command line usage string utility

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Robin Rosenberg <robin.rosenberg@xxxxxxxxxx>
---
 .../src/org/spearce/jgit/pgm/TextBuiltin.java      |   40 +++++++++++++++-----
 1 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/TextBuiltin.java b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/TextBuiltin.java
index 0746eb3..d0fe4af 100644
--- a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/TextBuiltin.java
+++ b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/TextBuiltin.java
@@ -127,22 +127,42 @@ protected void parseArguments(final String[] args) {
 		}
 
 		if (help) {
-			System.err.print("jgit ");
-			System.err.print(commandName);
-			clp.printSingleLineUsage(System.err);
-			System.err.println();
-
-			System.err.println();
-			clp.printUsage(System.err);
-			System.err.println();
-
-			System.exit(1);
+			printUsageAndExit(clp);
 		}
 
 		argWalk = clp.getRevWalkGently();
 	}
 
 	/**
+	 * Print the usage line
+	 *
+	 * @param clp
+	 */
+	public void printUsageAndExit(final CmdLineParser clp) {
+		printUsageAndExit("", clp);
+	}
+
+	/**
+	 * Print an error message and the usage line
+	 *
+	 * @param message
+	 * @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();
+
+		System.err.println();
+		clp.printUsage(System.err);
+		System.err.println();
+
+		System.exit(1);
+	}
+
+	/**
 	 * Perform the actions of this command.
 	 * <p>
 	 * This method should only be invoked by {@link #execute(String[])}.
-- 
1.6.0.1.310.gf789d0.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux