Implement out directory
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,5 +1,2 @@
|
|||||||
Test.lua
|
|
||||||
*.lua
|
*.lua
|
||||||
avorion-docparser.exe
|
avorion-docparser.exe
|
||||||
sync
|
|
||||||
test
|
|
3
main.go
3
main.go
@@ -45,6 +45,7 @@ var fns = template.FuncMap{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
outdir := flag.String("o", ".", "Output directory")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
files := flag.Args()
|
files := flag.Args()
|
||||||
// if len(files) == 0 {
|
// if len(files) == 0 {
|
||||||
@@ -70,7 +71,7 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
outfile, err := class.GetOutFile()
|
outfile, err := class.GetOutFile(*outdir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Error.Printf("Error creating output file: %v", err)
|
Error.Printf("Error creating output file: %v", err)
|
||||||
return
|
return
|
||||||
|
7
types.go
7
types.go
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -39,7 +40,7 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Class) GetOutFile() (*os.File, error) {
|
func (c *Class) GetOutFile(root string) (*os.File, error) {
|
||||||
if c.ClassName == "" {
|
if c.ClassName == "" {
|
||||||
return nil, fmt.Errorf("ClassName is empty")
|
return nil, fmt.Errorf("ClassName is empty")
|
||||||
}
|
}
|
||||||
@@ -48,7 +49,9 @@ func (c *Class) GetOutFile() (*os.File, error) {
|
|||||||
filename = strings.ReplaceAll(filename, "-", "")
|
filename = strings.ReplaceAll(filename, "-", "")
|
||||||
filename = strings.ReplaceAll(filename, ",", "")
|
filename = strings.ReplaceAll(filename, ",", "")
|
||||||
filename = strings.ReplaceAll(filename, ":", "")
|
filename = strings.ReplaceAll(filename, ":", "")
|
||||||
f, err := os.Create(filename)
|
filePath := filepath.Join(root, filename)
|
||||||
|
filePath = filepath.Clean(filePath)
|
||||||
|
f, err := os.Create(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user