-
Notifications
You must be signed in to change notification settings - Fork 0
/
option.go
55 lines (49 loc) · 1.81 KB
/
option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package protostub
// Option is a function type that modifies a ProtoStub.
// It allows setting optional parameters for ProtoStub configuration.
type Option func(*ProtoStub)
// WithProtoDir sets the directory where the .proto files are located.
// It returns an Option that modifies the ProtoDir field of a ProtoStub.
//
// protoDir: The directory path to the .proto files.
func WithProtoDir(protoDir string) Option {
return func(ps *ProtoStub) {
ps.ProtoDir = protoDir
}
}
// WithDestDir sets the destination directory for the generated Go and gRPC files.
// It returns an Option that modifies the DestDir field of a ProtoStub.
//
// destDir: The directory path where the generated code will be saved.
func WithDestDir(destDir string) Option {
return func(ps *ProtoStub) {
ps.DestDir = destDir
}
}
// WithServiceDir sets the destination directory for the generated service stub files.
// It returns an Option that modifies the serviceDir field of a ProtoStub.
//
// serviceDir: The directory path where the generated code will be saved.
func WithServiceDir(serviceDir string) Option {
return func(ps *ProtoStub) {
ps.ServiceDir = serviceDir
}
}
// WithClientDir sets the destination directory for the generated client stub files.
// It returns an Option that modifies the clientDir field of a ProtoStub.
//
// clientDir: The directory path where the generated code will be saved.
func WithClientDir(clientDir string) Option {
return func(ps *ProtoStub) {
ps.ClientDir = clientDir
}
}
// WithType sets the type of stub that will be generated (client or server).
// It returns an Option that modifies the type of the ProtoStub.
//
// typeName: The type of stub to generate, either ProtoStubServerType or ProtoStubClientType.
func WithType(typeName ProtoStubType) Option {
return func(ps *ProtoStub) {
ps.TypeName = typeName
}
}