buf icon indicating copy to clipboard operation
buf copied to clipboard

Allow exclude types

Open aria3ppp opened this issue 2 years ago • 2 comments

In the same way that --path and --exclude-path both exist together, I think it should be the same for --type and --exclude-type. So I think there should be an --exclude-type option that excludes types from building/generating!

aria3ppp avatar Sep 20 '23 08:09 aria3ppp

Can you explain what the use case is for this?

bufdev avatar Sep 20 '23 12:09 bufdev

Can you explain what the use case is for this?

Yup! Maybe my case is supper rare but i have many services:

package api;

service A {}
service B {}
service C {}
service D {}
service E {}

Among them there's two specific services: A and B It's a oneof situation: that means i need one of them at a time. So it's simple to just exclude one of them e.g. by --exclude-type api.A to build or generate and not include all other services one by one and just not mentioning api.A: --type api.B --type api.C --type api.D --type api.E

aria3ppp avatar Sep 20 '23 13:09 aria3ppp

Hi, for buf generate you can add an inputs section in buf.gen.yaml v2 to list out the types to generate. However, the --type flag is still needed for buf build.

# buf.gen.A.yaml
inputs:
  - directory: .
    types:
      - api.A
      - api.C
      - api.D
      - api.E

You can also create a buf.gen.B.yaml that contains everything but api.A. Then you can run buf generate --template buf.gen.A.yaml and vice versa.

oliversun9 avatar Jun 05 '24 22:06 oliversun9