Skip to content

Commit 1c0c994

Browse files
committed
Add flagcompletion to --container flag
Signed-off-by: Hadi Chokr <[email protected]>
1 parent 8b1e9ec commit 1c0c994

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/cmd/export.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,19 @@ var exportCmd = &cobra.Command{
3838
Use: "export",
3939
Short: "Export binaries or applications from a toolbox container",
4040
RunE: runExport,
41+
ValidArgsFunction: completionContainerNamesFiltered,
4142
}
4243

4344
func init() {
4445
exportCmd.Flags().StringVar(&exportBin, "bin", "", "Path or name of binary to export")
4546
exportCmd.Flags().StringVar(&exportApp, "app", "", "Path or name of application to export")
4647
exportCmd.Flags().StringVar(&exportContainer, "container", "", "Name of the toolbox container")
48+
49+
// Register container flag completion
50+
if err := exportCmd.RegisterFlagCompletionFunc("container", completionContainerNames); err != nil {
51+
panic(fmt.Sprintf("failed to register flag completion function: %v", err))
52+
}
53+
4754
exportCmd.SetHelpFunc(exportHelp)
4855
rootCmd.AddCommand(exportCmd)
4956
}

src/cmd/unexport.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,20 @@ var unexportCmd = &cobra.Command{
3838
Use: "unexport",
3939
Short: "Remove exported binaries and applications for a specific toolbox container",
4040
RunE: runUnexport,
41+
ValidArgsFunction: completionContainerNamesFiltered,
4142
}
4243

4344
func init() {
4445
unexportCmd.Flags().StringVar(&unexportContainer, "container", "", "Name of the toolbox container")
4546
unexportCmd.Flags().StringVar(&unexportBin, "bin", "", "Name of the exported binary to remove")
4647
unexportCmd.Flags().StringVar(&unexportApp, "app", "", "Name of the exported application to remove")
4748
unexportCmd.Flags().BoolVar(&unexportAll, "all", false, "Remove all exported binaries and applications for the container")
49+
50+
// Register container flag completion
51+
if err := unexportCmd.RegisterFlagCompletionFunc("container", completionContainerNames); err != nil {
52+
panic(fmt.Sprintf("failed to register flag completion function: %v", err))
53+
}
54+
4855
unexportCmd.SetHelpFunc(unexportHelp)
4956
rootCmd.AddCommand(unexportCmd)
5057
}

0 commit comments

Comments
 (0)