|
|
|
@ -133,7 +133,11 @@ public abstract class TextBuiltin {
|
|
|
|
|
commandName = name; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** @return true if {@link #db}/{@link #getRepository()} is required. */ |
|
|
|
|
/** |
|
|
|
|
* If this command requires a repository. |
|
|
|
|
* |
|
|
|
|
* @return true if {@link #db}/{@link #getRepository()} is required |
|
|
|
|
*/ |
|
|
|
|
protected boolean requiresRepository() { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
@ -214,7 +218,7 @@ public abstract class TextBuiltin {
|
|
|
|
|
* |
|
|
|
|
* @param args |
|
|
|
|
* command line arguments passed after the command name. |
|
|
|
|
* @throws Exception |
|
|
|
|
* @throws java.lang.Exception |
|
|
|
|
* an error occurred while processing the command. The main |
|
|
|
|
* framework will catch the exception and print a message on |
|
|
|
|
* standard error. |
|
|
|
@ -233,7 +237,7 @@ public abstract class TextBuiltin {
|
|
|
|
|
* |
|
|
|
|
* @param args |
|
|
|
|
* the arguments supplied on the command line, if any. |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
*/ |
|
|
|
|
protected void parseArguments(final String[] args) throws IOException { |
|
|
|
|
final CmdLineParser clp = new CmdLineParser(this); |
|
|
|
@ -260,7 +264,8 @@ public abstract class TextBuiltin {
|
|
|
|
|
* Print the usage line |
|
|
|
|
* |
|
|
|
|
* @param clp |
|
|
|
|
* @throws IOException |
|
|
|
|
* a {@link org.eclipse.jgit.pgm.opt.CmdLineParser} object. |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
*/ |
|
|
|
|
public void printUsageAndExit(final CmdLineParser clp) throws IOException { |
|
|
|
|
printUsageAndExit("", clp); //$NON-NLS-1$
|
|
|
|
@ -270,8 +275,10 @@ public abstract class TextBuiltin {
|
|
|
|
|
* Print an error message and the usage line |
|
|
|
|
* |
|
|
|
|
* @param message |
|
|
|
|
* a {@link java.lang.String} object. |
|
|
|
|
* @param clp |
|
|
|
|
* @throws IOException |
|
|
|
|
* a {@link org.eclipse.jgit.pgm.opt.CmdLineParser} object. |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
*/ |
|
|
|
|
public void printUsageAndExit(final String message, final CmdLineParser clp) throws IOException { |
|
|
|
|
printUsage(message, clp); |
|
|
|
@ -279,11 +286,13 @@ public abstract class TextBuiltin {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Print usage help text. |
|
|
|
|
* |
|
|
|
|
* @param message |
|
|
|
|
* non null |
|
|
|
|
* @param clp |
|
|
|
|
* parser used to print options |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* @since 4.2 |
|
|
|
|
*/ |
|
|
|
|
protected void printUsage(final String message, final CmdLineParser clp) |
|
|
|
@ -302,6 +311,8 @@ public abstract class TextBuiltin {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get error writer |
|
|
|
|
* |
|
|
|
|
* @return error writer, typically this is standard error. |
|
|
|
|
* @since 4.2 |
|
|
|
|
*/ |
|
|
|
@ -310,6 +321,8 @@ public abstract class TextBuiltin {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get output writer |
|
|
|
|
* |
|
|
|
|
* @return output writer, typically this is standard output. |
|
|
|
|
* @since 4.9 |
|
|
|
|
*/ |
|
|
|
@ -318,6 +331,8 @@ public abstract class TextBuiltin {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get resource bundle with localized texts |
|
|
|
|
* |
|
|
|
|
* @return the resource bundle that will be passed to args4j for purpose of |
|
|
|
|
* string localization |
|
|
|
|
*/ |
|
|
|
@ -330,7 +345,7 @@ public abstract class TextBuiltin {
|
|
|
|
|
* <p> |
|
|
|
|
* This method should only be invoked by {@link #execute(String[])}. |
|
|
|
|
* |
|
|
|
|
* @throws Exception |
|
|
|
|
* @throws java.lang.Exception |
|
|
|
|
* an error occurred while processing the command. The main |
|
|
|
|
* framework will catch the exception and print a message on |
|
|
|
|
* standard error. |
|
|
|
@ -338,6 +353,8 @@ public abstract class TextBuiltin {
|
|
|
|
|
protected abstract void run() throws Exception; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get the repository |
|
|
|
|
* |
|
|
|
|
* @return the repository this command accesses. |
|
|
|
|
*/ |
|
|
|
|
public Repository getRepository() { |
|
|
|
@ -352,6 +369,8 @@ public abstract class TextBuiltin {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Exit the command with an error message |
|
|
|
|
* |
|
|
|
|
* @param why |
|
|
|
|
* textual explanation |
|
|
|
|
* @return a runtime exception the caller is expected to throw |
|
|
|
@ -361,6 +380,8 @@ public abstract class TextBuiltin {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Exit the command with an error message and an exception |
|
|
|
|
* |
|
|
|
|
* @param why |
|
|
|
|
* textual explanation |
|
|
|
|
* @param cause |
|
|
|
@ -372,8 +393,11 @@ public abstract class TextBuiltin {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Exit the command |
|
|
|
|
* |
|
|
|
|
* @param aborted |
|
|
|
|
* boolean indicating that the execution has been aborted before running |
|
|
|
|
* boolean indicating that the execution has been aborted before |
|
|
|
|
* running |
|
|
|
|
* @return a runtime exception the caller is expected to throw |
|
|
|
|
* @since 3.4 |
|
|
|
|
*/ |
|
|
|
@ -382,6 +406,8 @@ public abstract class TextBuiltin {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Exit the command |
|
|
|
|
* |
|
|
|
|
* @param aborted |
|
|
|
|
* boolean indicating that the execution has been aborted before |
|
|
|
|
* running |
|
|
|
@ -405,6 +431,8 @@ public abstract class TextBuiltin {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Check if the arguments contain a help option |
|
|
|
|
* |
|
|
|
|
* @param args |
|
|
|
|
* non null |
|
|
|
|
* @return true if the given array contains help option |
|
|
|
|