mirror of https://github.com/docker/cli.git
Show plugins as Management commands
Plugins are expected to be management commands ("docker <object> <verb>"). This patch modified the usage output to shown plugins in the "Management commands" section. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
cdba45bd8b
commit
f8c5f5d9b8
|
@ -139,7 +139,7 @@ func hasInvalidPlugins(cmd *cobra.Command) bool {
|
||||||
func operationSubCommands(cmd *cobra.Command) []*cobra.Command {
|
func operationSubCommands(cmd *cobra.Command) []*cobra.Command {
|
||||||
cmds := []*cobra.Command{}
|
cmds := []*cobra.Command{}
|
||||||
for _, sub := range cmd.Commands() {
|
for _, sub := range cmd.Commands() {
|
||||||
if isPlugin(sub) && invalidPluginReason(sub) != "" {
|
if isPlugin(sub) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if sub.IsAvailableCommand() && !sub.HasSubCommands() {
|
if sub.IsAvailableCommand() && !sub.HasSubCommands() {
|
||||||
|
@ -179,7 +179,10 @@ func vendorAndVersion(cmd *cobra.Command) string {
|
||||||
func managementSubCommands(cmd *cobra.Command) []*cobra.Command {
|
func managementSubCommands(cmd *cobra.Command) []*cobra.Command {
|
||||||
cmds := []*cobra.Command{}
|
cmds := []*cobra.Command{}
|
||||||
for _, sub := range cmd.Commands() {
|
for _, sub := range cmd.Commands() {
|
||||||
if isPlugin(sub) && invalidPluginReason(sub) != "" {
|
if isPlugin(sub) {
|
||||||
|
if invalidPluginReason(sub) == "" {
|
||||||
|
cmds = append(cmds, sub)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if sub.IsAvailableCommand() && sub.HasSubCommands() {
|
if sub.IsAvailableCommand() && sub.HasSubCommands() {
|
||||||
|
@ -245,7 +248,7 @@ Management Commands:
|
||||||
Commands:
|
Commands:
|
||||||
|
|
||||||
{{- range operationSubCommands . }}
|
{{- range operationSubCommands . }}
|
||||||
{{rpad (decoratedName .) (add .NamePadding 1)}}{{.Short}}{{ if isPlugin .}} {{vendorAndVersion .}}{{ end}}
|
{{rpad .Name .NamePadding }} {{.Short}}
|
||||||
{{- end}}
|
{{- end}}
|
||||||
{{- end}}
|
{{- end}}
|
||||||
|
|
||||||
|
|
|
@ -41,10 +41,10 @@ func TestGlobalHelp(t *testing.T) {
|
||||||
regexp.MustCompile(`^A self-sufficient runtime for containers$`),
|
regexp.MustCompile(`^A self-sufficient runtime for containers$`),
|
||||||
regexp.MustCompile(`^Management Commands:$`),
|
regexp.MustCompile(`^Management Commands:$`),
|
||||||
regexp.MustCompile(`^ container\s+Manage containers$`),
|
regexp.MustCompile(`^ container\s+Manage containers$`),
|
||||||
|
helloworldre,
|
||||||
|
regexp.MustCompile(`^ image\s+Manage images$`),
|
||||||
regexp.MustCompile(`^Commands:$`),
|
regexp.MustCompile(`^Commands:$`),
|
||||||
regexp.MustCompile(`^ create\s+Create a new container$`),
|
regexp.MustCompile(`^ create\s+Create a new container$`),
|
||||||
helloworldre,
|
|
||||||
regexp.MustCompile(`^ ps\s+List containers$`),
|
|
||||||
regexp.MustCompile(`^Invalid Plugins:$`),
|
regexp.MustCompile(`^Invalid Plugins:$`),
|
||||||
badmetare,
|
badmetare,
|
||||||
nil, // scan to end of input rather than stopping at badmetare
|
nil, // scan to end of input rather than stopping at badmetare
|
||||||
|
|
Loading…
Reference in New Issue