Thread (3 messages) flat view 3 messages, 1 author, 2016-06-15
DORMANTno replies

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

From: Robin Rosenberg <hidden>
Date: 2016-06-15 22:45:24
Subsystem: the rest · Maintainer: Linus Torvalds

Signed-off-by: Robin Rosenberg <redacted>
---
 .../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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help