mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 17:05:43 +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.CmdLineException;
|
||||||
import org.kohsuke.args4j.CmdLineParser;
|
import org.kohsuke.args4j.CmdLineParser;
|
||||||
|
import org.kohsuke.args4j.Option;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -98,8 +99,17 @@ public abstract class SubCommand
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
parser.parseArgument(args);
|
parser.parseArgument(args);
|
||||||
|
|
||||||
|
if (help)
|
||||||
|
{
|
||||||
|
parser.printUsage(output, I18n.getBundle());
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (CmdLineException ex)
|
catch (CmdLineException ex)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -170,6 +180,14 @@ public abstract class SubCommand
|
|||||||
/** Field description */
|
/** Field description */
|
||||||
protected ScmClientSession session;
|
protected ScmClientSession session;
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
@Option(
|
||||||
|
name = "--help",
|
||||||
|
usage = "optionHelpText",
|
||||||
|
aliases = { "-h" }
|
||||||
|
)
|
||||||
|
private boolean help = false;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private boolean sessionRequired = true;
|
private boolean sessionRequired = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user