git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Robin Rosenberg <robin.rosenberg@dewire.com>
Date
Sep 24, 2008, 21:56 UTC
Message-ID
<1222293383-26016-1-git-send-email-robin.rosenberg@dewire.com>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 .../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
Next: Robin Rosenberg
Message 1 of 3 in “Include a print command line usage string utility”
  1. 1/3 Include a print command line usage string utilityRobin Rosenberg, Sep 24, 2008
  2. 2/3 Add create support to the branch commandRobin Rosenberg, Sep 24, 2008
  3. 3/3 Tell the branch dialog how to create a new branch.Robin Rosenberg, Sep 24, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.