Skip to content

Commit e61e09b

Browse files
authored
Only recursively expand .thrift files (#64)
Otherwise, we would attempt to parse non-Thrift nested within the directory hierarchy.
1 parent 24a104a commit e61e09b

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

README.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ command line tool (`thriftcheck`).
1010
the command line:
1111

1212
```
13-
usage: thriftcheck [options] [file ...]
13+
usage: thriftcheck [options] [path ...]
1414
-I, --include value
1515
include path (can be specified multiple times)
1616
-c, --config string
@@ -29,8 +29,11 @@ usage: thriftcheck [options] [file ...]
2929
print the version and exit
3030
```
3131

32-
You can lint from standard input by passing `-` as the sole filename. You can
33-
also use `--stdin-name` to customize the filename used in output messages.
32+
You can pass a list of filenames or directory paths. Directories will be
33+
expanded recursively to include all nested `.thrift` files.
34+
35+
You also can lint from standard input by passing `-` as the sole filename. You
36+
can also use `--stdin-name` to customize the filename used in output messages.
3437

3538
```sh
3639
$ thriftlint --stdin-name filename.thrift - < filename.thrift
@@ -43,12 +46,6 @@ file.thrift:1:1: error: "py" namespace must match "^idl\\." (namespace.pattern)
4346
file.thrift:3:1: error: unable to find include path for "bar.thrift" (include.path)
4447
```
4548

46-
You can also directly use the path of a directory to check all the Thrift files within the folder.
47-
48-
```sh
49-
$ thriftlint ./testdata
50-
```
51-
5249
If you only want errors (and not warnings) to be reported, you can use the
5350
`--errors-only` command line option.
5451

cmd/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ var (
8787
func init() {
8888
flag.Var(&includes, "I", "include path (can be specified multiple times)")
8989
flag.Usage = func() {
90-
fmt.Fprintf(flag.CommandLine.Output(), "usage: thriftcheck [options] [file ...]\n")
90+
fmt.Fprintf(flag.CommandLine.Output(), "usage: thriftcheck [options] [path ...]\n")
9191
getopt.PrintDefaults()
9292
}
9393
getopt.Aliases(
@@ -148,7 +148,7 @@ func expandPaths(paths []string) ([]string, error) {
148148
return err
149149
}
150150

151-
if !info.IsDir() {
151+
if !info.IsDir() && filepath.Ext(path) == ".thrift" {
152152
filenames = append(filenames, path)
153153
}
154154

0 commit comments

Comments
 (0)