-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator.go
45 lines (39 loc) · 1.14 KB
/
generator.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
package impligen
const (
// If the repository is not public or doesn't meet the requirements although required as such from the generator
ErrNotFound = 404
// If the code generation fails
ErrInternalServerError = 500
)
type (
// The generation parameters provided
Params struct {
// The path to the package to be imported
Path string
// The package name residing in the imported path
Package string
// The chosen type for the generic
Type string
// The suffix as an optional parameter, "" for the root
Suffix string
// Target path of an existing git repository where the files are to be generated
Target string
}
// The result of the code generation
GenResult struct {
// If the generation fails or the parameters don't meet the requirements, otherwise nil
Err error
}
// The generator-specific settings for impligen.
Settings struct {
// If only publically available repositories are allowed as generation argument
OnlyPublished bool
}
// To be implemented by the generator.
Genner interface {
// Get the parameters from the generator
Settings() Settings
// Generate the code now
Gen(params Params) GenResult
}
)