Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show plugins as Management commands #1684

Merged
merged 1 commit into from
Feb 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions cli/cobra.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func hasInvalidPlugins(cmd *cobra.Command) bool {
func operationSubCommands(cmd *cobra.Command) []*cobra.Command {
cmds := []*cobra.Command{}
for _, sub := range cmd.Commands() {
if isPlugin(sub) && invalidPluginReason(sub) != "" {
if isPlugin(sub) {
continue
}
if sub.IsAvailableCommand() && !sub.HasSubCommands() {
Expand Down Expand Up @@ -179,7 +179,10 @@ func vendorAndVersion(cmd *cobra.Command) string {
func managementSubCommands(cmd *cobra.Command) []*cobra.Command {
cmds := []*cobra.Command{}
for _, sub := range cmd.Commands() {
if isPlugin(sub) && invalidPluginReason(sub) != "" {
if isPlugin(sub) {
if invalidPluginReason(sub) == "" {
cmds = append(cmds, sub)
}
continue
}
if sub.IsAvailableCommand() && sub.HasSubCommands() {
Expand Down Expand Up @@ -245,7 +248,7 @@ Management Commands:
Commands:

{{- range operationSubCommands . }}
{{rpad (decoratedName .) (add .NamePadding 1)}}{{.Short}}{{ if isPlugin .}} {{vendorAndVersion .}}{{ end}}
{{rpad .Name .NamePadding }} {{.Short}}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored the original template for this line, as operationSubCommands now no longer contains plugins

{{- end}}
{{- end}}

Expand Down
4 changes: 2 additions & 2 deletions e2e/cli-plugins/help_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ func TestGlobalHelp(t *testing.T) {
regexp.MustCompile(`^A self-sufficient runtime for containers$`),
regexp.MustCompile(`^Management Commands:$`),
regexp.MustCompile(`^ container\s+Manage containers$`),
helloworldre,
thaJeztah marked this conversation as resolved.
Show resolved Hide resolved
regexp.MustCompile(`^ image\s+Manage images$`),
regexp.MustCompile(`^Commands:$`),
regexp.MustCompile(`^ create\s+Create a new container$`),
helloworldre,
regexp.MustCompile(`^ ps\s+List containers$`),
regexp.MustCompile(`^Invalid Plugins:$`),
badmetare,
nil, // scan to end of input rather than stopping at badmetare
Expand Down