@@ -11,6 +11,7 @@ import (
1111 "log"
1212 "os"
1313 "path/filepath"
14+ "regexp"
1415 "runtime/debug"
1516 "strings"
1617
@@ -314,6 +315,7 @@ func writeCodeGenerationComment(w io.StringWriter, args []string) {
314315func listTemplateCallersCommand (wd * string ) * cobra.Command {
315316 var config analysis.TemplateCallersConfiguration
316317
318+ var patterns []string
317319 cmd := & cobra.Command {
318320 Use : listTemplateCallersCommandName ,
319321 Aliases : []string {"callers" },
@@ -322,6 +324,13 @@ func listTemplateCallersCommand(wd *string) *cobra.Command {
322324 if config .TemplatesVariable == "" {
323325 config .TemplatesVariable = defaultTemplatesVariableName
324326 }
327+ for _ , pattern := range patterns {
328+ pat , err := regexp .Compile (pattern )
329+ if err != nil {
330+ return err
331+ }
332+ config .FilterTemplates = append (config .FilterTemplates , pat )
333+ }
325334
326335 fileSet , pl , err := asteval .LoadPackages (* wd )
327336 if err != nil {
@@ -336,13 +345,14 @@ func listTemplateCallersCommand(wd *string) *cobra.Command {
336345 }
337346
338347 addUseTemplatesVarToFlagSet (cmd .Flags (), & config .TemplatesVariable )
339- cmd .Flags ().StringArrayVar (& config . FilterTemplates , "template " , nil , "filter by template name (can specify multiple times )" )
348+ cmd .Flags ().StringArrayVar (& patterns , "match " , nil , "filter by template name (can specify multiple regular expressions )" )
340349
341350 return cmd
342351}
343352
344353func listTemplateCallsCommand (wd * string ) * cobra.Command {
345354 var config analysis.TemplateCallsConfiguration
355+ var patterns []string
346356
347357 cmd := & cobra.Command {
348358 Use : listTemplateCallsCommandName ,
@@ -352,6 +362,13 @@ func listTemplateCallsCommand(wd *string) *cobra.Command {
352362 if config .TemplatesVariable == "" {
353363 config .TemplatesVariable = defaultTemplatesVariableName
354364 }
365+ for _ , pattern := range patterns {
366+ pat , err := regexp .Compile (pattern )
367+ if err != nil {
368+ return err
369+ }
370+ config .FilterTemplates = append (config .FilterTemplates , pat )
371+ }
355372
356373 _ , pl , err := asteval .LoadPackages (* wd )
357374 if err != nil {
@@ -366,7 +383,7 @@ func listTemplateCallsCommand(wd *string) *cobra.Command {
366383 }
367384
368385 addUseTemplatesVarToFlagSet (cmd .Flags (), & config .TemplatesVariable )
369- cmd .Flags ().StringArrayVar (& config . FilterTemplates , "template " , nil , "filter by template name (can specify multiple times )" )
386+ cmd .Flags ().StringArrayVar (& patterns , "match " , nil , "filter by template name (can specify multiple regular expressions )" )
370387
371388 return cmd
372389}
0 commit comments