@@ -21,7 +21,7 @@ var Version = "0.0.0-src"
2121
2222var (
2323 focusFlag = flag .String ("focus" , "main" , "Focus package with name or import path." )
24- limitFlag = flag .String ("limit" , "" , "Limit package path to prefix." )
24+ limitFlag = flag .String ("limit" , "" , "Limit package paths to prefix. (separate multiple by comma) " )
2525 groupFlag = flag .String ("group" , "" , "Grouping functions by [pkg, type] (separate multiple by comma)." )
2626 ignoreFlag = flag .String ("ignore" , "" , "Ignore package paths with prefix (separate multiple by comma)." )
2727 testFlag = flag .Bool ("tests" , false , "Include test code." )
@@ -44,14 +44,6 @@ func main() {
4444 log .SetFlags (log .Lmicroseconds )
4545 }
4646
47- ignorePaths := []string {}
48- for _ , p := range strings .Split (* ignoreFlag , "," ) {
49- p = strings .TrimSpace (p )
50- if p != "" {
51- ignorePaths = append (ignorePaths , p )
52- }
53- }
54-
5547 groupBy := make (map [string ]bool )
5648 for _ , g := range strings .Split (* groupFlag , "," ) {
5749 g := strings .TrimSpace (g )
@@ -65,13 +57,29 @@ func main() {
6557 groupBy [g ] = true
6658 }
6759
68- if err := run (& build .Default , * focusFlag , * limitFlag , groupBy , ignorePaths , * testFlag , flag .Args ()); err != nil {
60+ limitPaths := []string {}
61+ for _ , p := range strings .Split (* limitFlag , "," ) {
62+ p = strings .TrimSpace (p )
63+ if p != "" {
64+ limitPaths = append (limitPaths , p )
65+ }
66+ }
67+
68+ ignorePaths := []string {}
69+ for _ , p := range strings .Split (* ignoreFlag , "," ) {
70+ p = strings .TrimSpace (p )
71+ if p != "" {
72+ ignorePaths = append (ignorePaths , p )
73+ }
74+ }
75+
76+ if err := run (& build .Default , * focusFlag , groupBy , limitPaths , ignorePaths , * testFlag , flag .Args ()); err != nil {
6977 fmt .Fprintf (os .Stderr , "go-callvis: %s\n " , err )
7078 os .Exit (1 )
7179 }
7280}
7381
74- func run (ctxt * build.Context , focus , limitPath string , groupBy map [string ]bool , ignorePaths []string , tests bool , args []string ) error {
82+ func run (ctxt * build.Context , focus string , groupBy map [string ]bool , limitPaths , ignorePaths []string , tests bool , args []string ) error {
7583 if len (args ) == 0 {
7684 return fmt .Errorf ("missing arguments" )
7785 }
@@ -154,7 +162,7 @@ func run(ctxt *build.Context, focus, limitPath string, groupBy map[string]bool,
154162 logf ("analysis took: %v" , time .Since (t0 ))
155163
156164 return printOutput (mains [0 ].Pkg , result .CallGraph ,
157- focusPkg , limitPath , ignorePaths , groupBy )
165+ focusPkg , limitPaths , ignorePaths , groupBy )
158166}
159167
160168func logf (f string , a ... interface {}) {
0 commit comments