mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 16:35:45 +01:00
list subcommands on help
This commit is contained in:
@@ -43,7 +43,9 @@ import org.kohsuke.args4j.Option;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import sonia.scm.cli.cmd.CommandDescriptor;
|
||||||
import sonia.scm.cli.cmd.SubCommand;
|
import sonia.scm.cli.cmd.SubCommand;
|
||||||
|
import sonia.scm.cli.cmd.SubCommandHandler;
|
||||||
import sonia.scm.cli.cmd.SubCommandOptionHandler;
|
import sonia.scm.cli.cmd.SubCommandOptionHandler;
|
||||||
import sonia.scm.cli.config.ConfigOptionHandler;
|
import sonia.scm.cli.config.ConfigOptionHandler;
|
||||||
import sonia.scm.cli.config.ScmClientConfig;
|
import sonia.scm.cli.config.ScmClientConfig;
|
||||||
@@ -151,6 +153,14 @@ public class App
|
|||||||
if ((args.length == 0) || (subcommand == null) || help)
|
if ((args.length == 0) || (subcommand == null) || help)
|
||||||
{
|
{
|
||||||
parser.printUsage(output, i18n.getBundle());
|
parser.printUsage(output, i18n.getBundle());
|
||||||
|
output.println();
|
||||||
|
output.println(i18n.getMessage(I18n.SUBCOMMANDS_TITLE));
|
||||||
|
|
||||||
|
for (CommandDescriptor desc :
|
||||||
|
SubCommandHandler.getInstance().getDescriptors())
|
||||||
|
{
|
||||||
|
output.append(" ").println(desc.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ public class I18n
|
|||||||
/** Field description */
|
/** Field description */
|
||||||
public static final String RESOURCE_BUNDLE = "sonia.resources.i18n";
|
public static final String RESOURCE_BUNDLE = "sonia.resources.i18n";
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
public static final String SUBCOMMANDS_TITLE = "subCommandsTitle";
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
public static final String USER_NOT_FOUND = "userNotFound";
|
public static final String USER_NOT_FOUND = "userNotFound";
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ import sonia.scm.util.Util;
|
|||||||
*
|
*
|
||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
*/
|
*/
|
||||||
public class CommandDescriptor
|
public class CommandDescriptor implements Comparable<CommandDescriptor>
|
||||||
{
|
{
|
||||||
|
|
||||||
/** the logger for CommandDescriptor */
|
/** the logger for CommandDescriptor */
|
||||||
@@ -97,6 +97,20 @@ public class CommandDescriptor
|
|||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param desc
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int compareTo(CommandDescriptor desc)
|
||||||
|
{
|
||||||
|
return name.compareTo(desc.name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -50,8 +50,11 @@ import java.io.InputStreamReader;
|
|||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,6 +124,22 @@ public class SubCommandHandler
|
|||||||
return subCommands.get(name);
|
return subCommands.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<CommandDescriptor> getDescriptors()
|
||||||
|
{
|
||||||
|
List<CommandDescriptor> descs =
|
||||||
|
new ArrayList<CommandDescriptor>(subCommands.values());
|
||||||
|
|
||||||
|
Collections.sort(descs);
|
||||||
|
|
||||||
|
return descs;
|
||||||
|
}
|
||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -30,6 +30,8 @@
|
|||||||
VAL = value
|
VAL = value
|
||||||
FILE = file
|
FILE = file
|
||||||
|
|
||||||
|
subCommandsTitle = SubCommands
|
||||||
|
|
||||||
optionConfig = Configuration name
|
optionConfig = Configuration name
|
||||||
optionServerUrl = SCM-Manager URL
|
optionServerUrl = SCM-Manager URL
|
||||||
optionUsername = Username
|
optionUsername = Username
|
||||||
|
|||||||
Reference in New Issue
Block a user