diff --git a/pkg/commands/options/filestuff.go b/pkg/commands/options/filestuff.go index 2820aa5468..4c547b0cb8 100644 --- a/pkg/commands/options/filestuff.go +++ b/pkg/commands/options/filestuff.go @@ -34,6 +34,18 @@ func AddFileArg(cmd *cobra.Command, fo *FilenameOptions) { "Filename, directory, or URL to files to use to create the resource") cmd.Flags().BoolVarP(&fo.Recursive, "recursive", "R", fo.Recursive, "Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.") + + if err := cmd.MarkFlagFilename("filename", "yaml", "yml", "json"); err != nil { + log.Fatalf("Error marking filename flag as Cobra's filename: %v", err) + } + + if err := cmd.MarkFlagDirname("filename"); err != nil { + log.Fatalf("Error marking filename flag as Cobra's Dirname: %v", err) + } + + if err := cmd.MarkFlagRequired("filename"); err != nil { + log.Fatalf("Error marking filename flag as required: %v", err) + } } // Based heavily on pkg/kubectl