-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathormc_handler.go
More file actions
35 lines (28 loc) · 839 Bytes
/
ormc_handler.go
File metadata and controls
35 lines (28 loc) · 839 Bytes
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
//go:build !wasm
package orm
// Ormc is the code generator handler for the ormc tool.
type Ormc struct {
logFn func(messages ...any)
rootDir string
}
// NewOrmc creates a new Ormc handler with rootDir defaulting to ".".
func NewOrmc() *Ormc {
return &Ormc{rootDir: "."}
}
// SetLog sets the log function for warnings and informational messages.
// If not set, messages are silently discarded.
func (o *Ormc) SetLog(fn func(messages ...any)) {
o.logFn = fn
}
// SetRootDir sets the root directory that Run() will scan.
// Defaults to ".". Useful in tests to point to a specific directory
// without needing os.Chdir.
func (o *Ormc) SetRootDir(dir string) {
o.rootDir = dir
}
// log emits a message via the configured log function, if any.
func (o *Ormc) log(messages ...any) {
if o.logFn != nil {
o.logFn(messages...)
}
}