Disallow use of --include-content without --filter

This commit is contained in:
Tyler McGoffin 2024-10-10 11:12:24 -07:00 committed by Heath Stewart
parent 73af9f8bd9
commit b56353dc02
No known key found for this signature in database
2 changed files with 11 additions and 0 deletions

View file

@ -65,6 +65,12 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman
return cmdutil.FlagErrorf("invalid limit: %v", opts.Limit)
}
if flagFilter == "" {
if opts.IncludeContent {
return cmdutil.FlagErrorf("cannot use --include-content without --filter")
}
}
if filter, err := regexp.CompilePOSIX(flagFilter); err != nil {
return err
} else {

View file

@ -92,6 +92,11 @@ func TestNewCmdList(t *testing.T) {
cli: "--filter octo(",
wantsErr: true,
},
{
name: "include content without filter",
cli: "--include-content",
wantsErr: true,
},
}
for _, tt := range tests {