Skip to content

Commit

Permalink
chore: Add a note about sh dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
yoheimuta committed Jan 17, 2021
1 parent f309b98 commit 64d3990
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
9 changes: 7 additions & 2 deletions _example/plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### Build

```bash
go build main.go
go build -o plugin_example main.go
```

NOTE: protolint plugin is backed by [hashicorp/go-plugin](https://github.com/hashicorp/go-plugin), not the [plugin](https://golang.org/pkg/plugin/) standard library.
Expand All @@ -13,5 +13,10 @@ Therefore, you can build the plugin just as a normal Go main package.
### Run

```bash
protolint -plugin ./your_plugin_binary /path/to/files
protolint -plugin ./plugin_example /path/to/files

# Or you can pass some flags to your plugin:
protolint -plugin "./plugin_example -go_style=false" /path/to/files
```

NOTE: `sh` must be in your PATH.
10 changes: 9 additions & 1 deletion _example/plugin/main.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
package main

import (
"flag"

"github.com/yoheimuta/protolint/_example/plugin/customrules"
"github.com/yoheimuta/protolint/internal/addon/rules"
"github.com/yoheimuta/protolint/linter/rule"
"github.com/yoheimuta/protolint/plugin"
)

var (
goStyle = flag.Bool("go_style", true, "the comments should follow a golang style")
)

func main() {
flag.Parse()

plugin.RegisterCustomRules(
// The purpose of this line just illustrates that you can implement the same as internal linter rules.
rules.NewEnumsHaveCommentRule(true),
rules.NewEnumsHaveCommentRule(*goStyle),

// A common custom rule example. It's simple.
customrules.NewEnumNamesLowerSnakeCaseRule(),
Expand Down

0 comments on commit 64d3990

Please sign in to comment.