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

Re: [JGIT PATCH 17/28] Support automatic command line parsing for TextBuiltin subclasses

From
FKFlorian Köberle <florianskarten@web.de>
Date
Jul 18, 2008, 19:01 UTC
Message-ID
<4880E880.1010403@web.de>
Hi Shawn

to use args4j was really a great idea. I had a patch, implementing something similar to args4j in my repository, but using a library is always better. *thumb up*

I had a short look at the files and noticed that the inner "if (help) {" is unnecessary:

+ if (help) { + System.err.print("jgit "); + System.err.print(commandName); + clp.printSingleLineUsage(System.err); + System.err.println(); + + if (help) { + System.err.println(); + clp.printUsage(System.err); + System.err.println(); + } + System.exit(1); + }

Also a cool function which you may want to use is:
public <U> Class<? extends U> asSubclass(Class<U> clazz)

With that method of Class<?> you can do the cast before you actually create the object. You could for example make use of them in SubcommandHandler: l. 124 cmd = (TextBuiltin) cons.newInstance();

Best regards, Florian Köberle

Next: Shawn O. Pearce
Message 1 of 2 in “Re: [JGIT PATCH 17/28] Support automatic command line parsing for TextBuiltin subclasses”
  1. Florian KöberleJul 18, 2008
  2. Shawn O. PearceJul 18, 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.