added completion to overlay chmod/chown/delete/edit

Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
Christian Goll
2024-07-09 15:54:32 +02:00
committed by Jonathon Anderson
parent 1418d091a8
commit c9c38542f4
5 changed files with 37 additions and 16 deletions

View File

@@ -44,6 +44,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added
- Show more information during `wwctl container <shell|exec>` about when and if the container image will be rebuilt. #1302
- Command-line completion for `wwctl overlay <edit|delete|chmod|chown>`. #1298
### Fixed

View File

@@ -15,11 +15,16 @@ var (
RunE: CobraRunE,
Args: cobra.ExactArgs(3),
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) != 0 {
return nil, cobra.ShellCompDirectiveNoFileComp
if len(args) == 0 {
list, _ := overlay.FindOverlays()
return list, cobra.ShellCompDirectiveNoFileComp
} else if len(args) == 1 {
ret, err := overlay.OverlayGetFiles(args[0])
if err == nil {
return ret, cobra.ShellCompDirectiveNoFileComp
}
}
list, _ := overlay.FindOverlays()
return list, cobra.ShellCompDirectiveNoFileComp
return []string{""}, cobra.ShellCompDirectiveNoFileComp
},
}
)

View File

@@ -14,11 +14,16 @@ var (
RunE: CobraRunE,
Args: cobra.RangeArgs(3, 4),
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) != 0 {
return nil, cobra.ShellCompDirectiveNoFileComp
if len(args) == 0 {
list, _ := overlay.FindOverlays()
return list, cobra.ShellCompDirectiveNoFileComp
} else if len(args) == 1 {
ret, err := overlay.OverlayGetFiles(args[0])
if err == nil {
return ret, cobra.ShellCompDirectiveNoFileComp
}
}
list, _ := overlay.FindOverlays()
return list, cobra.ShellCompDirectiveNoFileComp
return []string{""}, cobra.ShellCompDirectiveNoFileComp
},
}
)

View File

@@ -15,11 +15,16 @@ var (
Args: cobra.RangeArgs(1, 2),
Aliases: []string{"rm", "remove", "del"},
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) != 0 {
return nil, cobra.ShellCompDirectiveNoFileComp
if len(args) == 0 {
list, _ := overlay.FindOverlays()
return list, cobra.ShellCompDirectiveNoFileComp
} else if len(args) == 1 {
ret, err := overlay.OverlayGetFiles(args[0])
if err == nil {
return ret, cobra.ShellCompDirectiveNoFileComp
}
}
list, _ := overlay.FindOverlays()
return list, cobra.ShellCompDirectiveNoFileComp
return []string{""}, cobra.ShellCompDirectiveNoFileComp
},
}
Force bool

View File

@@ -14,11 +14,16 @@ var (
RunE: CobraRunE,
Args: cobra.ExactArgs(2),
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) != 0 {
return nil, cobra.ShellCompDirectiveNoFileComp
if len(args) == 0 {
list, _ := overlay.FindOverlays()
return list, cobra.ShellCompDirectiveNoFileComp
} else if len(args) == 1 {
ret, err := overlay.OverlayGetFiles(args[0])
if err == nil {
return ret, cobra.ShellCompDirectiveNoFileComp
}
}
list, _ := overlay.FindOverlays()
return list, cobra.ShellCompDirectiveNoFileComp
return []string{""}, cobra.ShellCompDirectiveNoFileComp
},
}
CreateDirs bool