Slightly cleaner generation structure
This commit is contained in:
parent
903fe9fbfd
commit
06a26af5ba
|
@ -5,6 +5,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := os.Create("empty.go")
|
f, err := os.Create(filepath.Join(os.Args[1], "empty.go"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("Failed to create output file:", err)
|
log.Fatalln("Failed to create output file:", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,11 @@ func main() {
|
||||||
for pkgPath, pkg := range repository.Main {
|
for pkgPath, pkg := range repository.Main {
|
||||||
g := generate(pkgPath, pkg)
|
g := generate(pkgPath, pkg)
|
||||||
|
|
||||||
var destDir = filepath.FromSlash(trimPrefix(repository.RootPath, pkgPath))
|
destDir := filepath.Join(
|
||||||
var destFle = filepath.Base(pkgPath)
|
os.Args[1],
|
||||||
|
filepath.FromSlash(trimPrefix(repository.RootPath, pkgPath)),
|
||||||
|
)
|
||||||
|
destFile := filepath.Base(pkgPath) + ".go"
|
||||||
|
|
||||||
// Guarantee that the directory exists.
|
// Guarantee that the directory exists.
|
||||||
if destDir != "" {
|
if destDir != "" {
|
||||||
|
@ -31,7 +34,7 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := os.Create(filepath.Join(destDir, destFle+".go"))
|
f, err := os.Create(filepath.Join(destDir, destFile))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("Failed to create output file:", err)
|
log.Fatalln("Failed to create output file:", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package cchat
|
package cchat
|
||||||
|
|
||||||
//go:generate go run ./cmd/internal/cchat-generator
|
//go:generate go run ./cmd/internal/cchat-generator ./
|
||||||
|
//go:generate go run ./cmd/internal/cchat-empty-gen ./utils/empty/
|
||||||
|
|
||||||
type authenticateError struct{ error }
|
type authenticateError struct{ error }
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,10 @@ func (c Comment) IsEmpty() bool {
|
||||||
// prefix each line with "// ". The ident argument controls the nested level. If
|
// prefix each line with "// ". The ident argument controls the nested level. If
|
||||||
// less than or equal to zero, then it is changed to 1, which is the top level.
|
// less than or equal to zero, then it is changed to 1, which is the top level.
|
||||||
func (c Comment) GoString(ident int) string {
|
func (c Comment) GoString(ident int) string {
|
||||||
|
if c.Raw == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
if ident < 1 {
|
if ident < 1 {
|
||||||
ident = 1
|
ident = 1
|
||||||
}
|
}
|
||||||
|
@ -40,7 +44,12 @@ func (c Comment) GoString(ident int) string {
|
||||||
|
|
||||||
var lines = strings.Split(c.WrapText(80-len("// ")-ident), "\n")
|
var lines = strings.Split(c.WrapText(80-len("// ")-ident), "\n")
|
||||||
for i, line := range lines {
|
for i, line := range lines {
|
||||||
lines[i] = "// " + line
|
if line != "" {
|
||||||
|
line = "// " + line
|
||||||
|
} else {
|
||||||
|
line = "//"
|
||||||
|
}
|
||||||
|
lines[i] = line
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Join(lines, "\n")
|
return strings.Join(lines, "\n")
|
||||||
|
|
Binary file not shown.
|
@ -1,3 +0,0 @@
|
||||||
package empty
|
|
||||||
|
|
||||||
//go:generate go run ../../cmd/internal/cchat-empty-gen
|
|
Loading…
Reference in New Issue