summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/common/completion.go7
-rw-r--r--cmd/podman/common/completion_test.go4
2 files changed, 5 insertions, 6 deletions
diff --git a/cmd/podman/common/completion.go b/cmd/podman/common/completion.go
index 6f13eb5a2..ddf922b2a 100644
--- a/cmd/podman/common/completion.go
+++ b/cmd/podman/common/completion.go
@@ -1056,13 +1056,12 @@ func getStructFields(f reflect.Value, prefix string) []string {
if kind == reflect.Struct {
suffix = "."
}
- if strings.HasPrefix(fname, prefix) {
- // add field name with suffix
- suggestions = append(suggestions, fname+suffix)
- }
// if field is anonymous add the child fields as well
if field.Anonymous {
suggestions = append(suggestions, getStructFields(f.Field(j), prefix)...)
+ } else if strings.HasPrefix(fname, prefix) {
+ // add field name with suffix
+ suggestions = append(suggestions, fname+suffix)
}
}
diff --git a/cmd/podman/common/completion_test.go b/cmd/podman/common/completion_test.go
index bfff9a96e..ae117a173 100644
--- a/cmd/podman/common/completion_test.go
+++ b/cmd/podman/common/completion_test.go
@@ -79,12 +79,12 @@ func TestAutocompleteFormat(t *testing.T) {
{
"fist level struct field name",
"{{.",
- []string{"{{.Name}}", "{{.Age}}", "{{.Car.", "{{.Car2.", "{{.Anonymous.", "{{.Hello}}"},
+ []string{"{{.Name}}", "{{.Age}}", "{{.Car.", "{{.Car2.", "{{.Hello}}"},
},
{
"fist level struct field name",
"{{ .",
- []string{"{{ .Name}}", "{{ .Age}}", "{{ .Car.", "{{ .Car2.", "{{ .Anonymous.", "{{ .Hello}}"},
+ []string{"{{ .Name}}", "{{ .Age}}", "{{ .Car.", "{{ .Car2.", "{{ .Hello}}"},
},
{
"fist level struct field name",