File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ genrule(
44
44
"//:all-srcs" ,
45
45
],
46
46
outs = ["stable-metrics-list.yaml" ],
47
- cmd = "./$(locations :instrumentation) $(locations //:all-srcs) > $@" ,
47
+ cmd = "for loc in $(locations //:all-srcs); do echo $$loc; done | ./$(locations :instrumentation) - > $@" ,
48
48
message = "Listing all stable metrics." ,
49
49
tools = [":instrumentation" ],
50
50
)
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ limitations under the License.
17
17
package main
18
18
19
19
import (
20
+ "bufio"
20
21
"flag"
21
22
"fmt"
22
23
"go/ast"
@@ -42,18 +43,34 @@ const (
42
43
func main () {
43
44
flag .Parse ()
44
45
if len (flag .Args ()) < 1 {
45
- fmt .Fprintf (os .Stderr , "USAGE: %s <DIR or FILE> [...]\n " , os .Args [0 ])
46
+ fmt .Fprintf (os .Stderr , "USAGE: %s <DIR or FILE or '-' > [...]\n " , os .Args [0 ])
46
47
os .Exit (64 )
47
48
}
48
49
49
50
stableMetrics := []metric {}
50
51
errors := []error {}
51
52
53
+ addStdin := false
52
54
for _ , arg := range flag .Args () {
55
+ if arg == "-" {
56
+ addStdin = true
57
+ continue
58
+ }
53
59
ms , es := searchPathForStableMetrics (arg )
54
60
stableMetrics = append (stableMetrics , ms ... )
55
61
errors = append (errors , es ... )
56
62
}
63
+ if addStdin {
64
+ scanner := bufio .NewScanner (os .Stdin )
65
+ scanner .Split (bufio .ScanLines )
66
+ for scanner .Scan () {
67
+ arg := scanner .Text ()
68
+ ms , es := searchPathForStableMetrics (arg )
69
+ stableMetrics = append (stableMetrics , ms ... )
70
+ errors = append (errors , es ... )
71
+ }
72
+ }
73
+
57
74
for _ , err := range errors {
58
75
fmt .Fprintf (os .Stderr , "%s\n " , err )
59
76
}
You can’t perform that action at this time.
0 commit comments