mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 16:35:45 +01:00
added help option to SubCommand
This commit is contained in:
@@ -37,6 +37,7 @@ package sonia.scm.cli;
|
||||
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.Option;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -98,7 +99,16 @@ public abstract class SubCommand
|
||||
try
|
||||
{
|
||||
parser.parseArgument(args);
|
||||
run();
|
||||
|
||||
if (help)
|
||||
{
|
||||
parser.printUsage(output, I18n.getBundle());
|
||||
System.exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
run();
|
||||
}
|
||||
}
|
||||
catch (CmdLineException ex)
|
||||
{
|
||||
@@ -170,6 +180,14 @@ public abstract class SubCommand
|
||||
/** Field description */
|
||||
protected ScmClientSession session;
|
||||
|
||||
/** Field description */
|
||||
@Option(
|
||||
name = "--help",
|
||||
usage = "optionHelpText",
|
||||
aliases = { "-h" }
|
||||
)
|
||||
private boolean help = false;
|
||||
|
||||
/** Field description */
|
||||
private boolean sessionRequired = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user