mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 08:55:44 +01:00
added groups for subcommands
This commit is contained in:
@@ -152,15 +152,7 @@ public class App
|
||||
|
||||
if ((args.length == 0) || (subcommand == null) || help)
|
||||
{
|
||||
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());
|
||||
}
|
||||
printHelp(parser, i18n);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -199,6 +191,37 @@ public class App
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param parser
|
||||
* @param i18n
|
||||
*/
|
||||
private void printHelp(CmdLineParser parser, I18n i18n)
|
||||
{
|
||||
parser.printUsage(output, i18n.getBundle());
|
||||
output.println();
|
||||
output.println(i18n.getMessage(I18n.SUBCOMMANDS_TITLE));
|
||||
output.println();
|
||||
|
||||
String group = null;
|
||||
|
||||
for (CommandDescriptor desc :
|
||||
SubCommandHandler.getInstance().getDescriptors())
|
||||
{
|
||||
if ((group == null) ||!group.equals(desc.getGroup()))
|
||||
{
|
||||
output.println();
|
||||
group = desc.getGroup();
|
||||
output.append(i18n.getMessage(group)).println(":");
|
||||
output.println();
|
||||
}
|
||||
|
||||
output.append(" ").println(desc.getName());
|
||||
}
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
|
||||
@@ -45,7 +45,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("add-members")
|
||||
@Command(name = "add-members", group = "group")
|
||||
public class AddMembersSubCommand extends MembersSubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("add-permission")
|
||||
@Command(name="add-permission", group="repository")
|
||||
public class AddPermissionSubCommand extends PermissionSubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Command
|
||||
{
|
||||
String value() default "";
|
||||
String name() default "";
|
||||
String usage() default "";
|
||||
String group() default "misc";
|
||||
}
|
||||
|
||||
@@ -69,7 +69,8 @@ public class CommandDescriptor implements Comparable<CommandDescriptor>
|
||||
|
||||
if (cmd != null)
|
||||
{
|
||||
this.name = cmd.value();
|
||||
this.name = cmd.name();
|
||||
this.group = cmd.group();
|
||||
this.usage = cmd.usage();
|
||||
}
|
||||
|
||||
@@ -108,7 +109,14 @@ public class CommandDescriptor implements Comparable<CommandDescriptor>
|
||||
@Override
|
||||
public int compareTo(CommandDescriptor desc)
|
||||
{
|
||||
return name.compareTo(desc.name);
|
||||
int result = group.compareTo(desc.group);
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
result = name.compareTo(desc.name);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,6 +155,17 @@ public class CommandDescriptor implements Comparable<CommandDescriptor>
|
||||
return commandClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getGroup()
|
||||
{
|
||||
return group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -174,6 +193,9 @@ public class CommandDescriptor implements Comparable<CommandDescriptor>
|
||||
/** Field description */
|
||||
private Class<? extends SubCommand> commandClass;
|
||||
|
||||
/** Field description */
|
||||
private String group = "misc";
|
||||
|
||||
/** Field description */
|
||||
private String name;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("create-group")
|
||||
@Command(name="create-group", group="group")
|
||||
public class CreateGroupSubCommand extends TemplateSubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("create-repository")
|
||||
@Command(name="create-repository",group="repository")
|
||||
public class CreateRepositorySubCommand extends TemplateSubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("create-user")
|
||||
@Command(name="create-user", group="user")
|
||||
public class CreateUserSubCommand extends TemplateSubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import sonia.scm.cli.config.ScmClientConfig;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("delete-config")
|
||||
@Command(name="delete-config", group="config")
|
||||
public class DeleteConfigSubCommand extends SubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ import sonia.scm.client.ScmClientSession;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("delete-group")
|
||||
@Command(name="delete-group",group="group")
|
||||
public class DeleteGroupSubCommand extends SubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("delete-members")
|
||||
@Command(name="delete-members",group="group")
|
||||
public class DeleteMembersSubCommand extends MembersSubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("delete-permission")
|
||||
@Command(name="delete-permission",group="repository")
|
||||
public class DeletePermissionSubCommand extends PermissionSubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ import sonia.scm.client.ScmClientSession;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("delete-repository")
|
||||
@Command(name="delete-repository",group="repository")
|
||||
public class DeleteRepositorySubCommand extends SubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ import sonia.scm.client.ScmClientSession;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("delete-user")
|
||||
@Command(name="delete-user",group="user")
|
||||
public class DeleteUserSubCommand extends SubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("get-group")
|
||||
@Command(name="get-group",group="group")
|
||||
public class GetGroupSubCommand extends TemplateSubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("get-repository")
|
||||
@Command(name="get-repository",group="repository")
|
||||
public class GetRepositorySubCommand extends TemplateSubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("get-user")
|
||||
@Command(name="get-user",group="user")
|
||||
public class GetUserSubCommand extends TemplateSubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("list-groups")
|
||||
@Command(name="list-groups",group="group")
|
||||
public class ListGroupsSubCommand extends TemplateSubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("list-repositories")
|
||||
@Command(name="list-repositories",group="repository")
|
||||
public class ListRepositoriesSubCommand extends TemplateSubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("list-users")
|
||||
@Command(name="list-users",group="user")
|
||||
public class ListUsersSubCommand extends TemplateSubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("modify-group")
|
||||
@Command(name="modify-group",group="group")
|
||||
public class ModifyGroupSubCommand extends TemplateSubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("modify-repository")
|
||||
@Command(name="modify-repository",group="repository")
|
||||
public class ModifyRepositorySubCommand extends TemplateSubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("modify-user")
|
||||
@Command(name="modify-user",group="user")
|
||||
public class ModifyUserSubCommand extends TemplateSubCommand
|
||||
{
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import sonia.scm.cli.config.ScmClientConfig;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Command("store-config")
|
||||
@Command(name = "store-config", group = "config")
|
||||
public class StoreConfigSubCommand extends SubCommand
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user