|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jgit.pgm.TextBuiltin
public abstract class TextBuiltin
Abstract command which can be invoked from the command line.
Commands are configured with a single "current" repository and then the
execute(String[])
method is invoked with the arguments that appear
on the command line after the command name.
Command constructors should perform as little work as possible as they may be invoked very early during process loading, and the command may not execute even though it was constructed.
Field Summary | |
---|---|
protected RevWalk |
argWalk
RevWalk used during command line parsing, if it was required. |
protected Repository |
db
Git repository the command was invoked within. |
protected java.lang.String |
gitdir
Directory supplied via --git-dir command line option. |
protected java.io.PrintWriter |
out
Stream to output to, typically this is standard output. |
Constructor Summary | |
---|---|
TextBuiltin()
|
Method Summary | |
---|---|
protected static Die |
die(java.lang.String why)
|
protected static Die |
die(java.lang.String why,
java.lang.Throwable cause)
|
void |
execute(java.lang.String[] args)
Parse arguments and run this command. |
Repository |
getRepository()
|
protected java.util.ResourceBundle |
getResourceBundle()
|
protected void |
init(Repository repository,
java.lang.String gitDir)
Initialize the command to work with a repository. |
protected void |
parseArguments(java.lang.String[] args)
Parses the command line arguments prior to running. |
void |
printUsageAndExit(CmdLineParser clp)
Print the usage line |
void |
printUsageAndExit(java.lang.String message,
CmdLineParser clp)
Print an error message and the usage line |
protected boolean |
requiresRepository()
|
protected abstract void |
run()
Perform the actions of this command. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.io.PrintWriter out
protected Repository db
protected java.lang.String gitdir
protected RevWalk argWalk
Constructor Detail |
---|
public TextBuiltin()
Method Detail |
---|
protected boolean requiresRepository()
db
/getRepository()
is required.protected void init(Repository repository, java.lang.String gitDir)
repository
- the opened repository that the command should work on.gitDir
- value of the --git-dir
command line option, if
repository
is null.public final void execute(java.lang.String[] args) throws java.lang.Exception
args
- command line arguments passed after the command name.
java.lang.Exception
- an error occurred while processing the command. The main
framework will catch the exception and print a message on
standard error.protected void parseArguments(java.lang.String[] args)
This method should only be invoked by execute(String[])
, prior
to calling run()
. The default implementation parses all
arguments into this object's instance fields.
args
- the arguments supplied on the command line, if any.public void printUsageAndExit(CmdLineParser clp)
clp
- public void printUsageAndExit(java.lang.String message, CmdLineParser clp)
message
- clp
- protected java.util.ResourceBundle getResourceBundle()
protected abstract void run() throws java.lang.Exception
This method should only be invoked by execute(String[])
.
java.lang.Exception
- an error occurred while processing the command. The main
framework will catch the exception and print a message on
standard error.public Repository getRepository()
protected static Die die(java.lang.String why)
why
- textual explanation
protected static Die die(java.lang.String why, java.lang.Throwable cause)
why
- textual explanationcause
- why the command has failed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |