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