该版本仍在开发中,尚未被视为稳定。最新稳定版本请使用Spring Shell 3.4.1spring-doc.cadn.net.cn

组织指挥

当你的壳开始提供大量功能时,你可能会 命令很多,可能会让用户感到困惑。通过打字帮助, 他们会看到一长串按字母顺序排列的命令清单, 这可能并不总是显示可用命令的最佳方式。spring-doc.cadn.net.cn

为了消除这种可能的混淆,Spring Shell 提供了将命令组合在一起的功能, 而且有合理的违约率。相关命令随后会回到同一组(例如,用户管理命令) 并会一起显示在帮助界面和其他地方。spring-doc.cadn.net.cn

默认情况下,命令被分组到默认值群。不过,你可以覆盖 命令按优先级顺序按以下方式:spring-doc.cadn.net.cn

  1. 指定一个组()@Command方法注释。spring-doc.cadn.net.cn

  2. 指定一个组()@Command对命令定义的类进行注释。这同样适用 该类中定义的所有命令的组(除非被覆盖,如前所述)。spring-doc.cadn.net.cn

以下列表展示了一个示例:spring-doc.cadn.net.cn

@Command
public class UserCommands {
    @Command(description = "This command ends up in the 'Default' group")
    public void foo() {}

    @Command(description = "This command ends up in the 'Other Commands' group",
    	group = "Other Commands")
    public void bar() {}
}

...

@Command(group = "Other Commands")
public class SomeCommands {
	@Command(description = "This one is in 'Other Commands'")
	public void wizz() {}

	@Command(description = "And this one is 'Yet Another Group'",
		group = "Yet Another Group")
	public void last() {}
}