feat(cli): customize public dir
This commit is contained in:
parent
3b37150f6e
commit
614a654824
1 changed files with 15 additions and 8 deletions
11
main.go
11
main.go
|
@ -24,6 +24,7 @@ var (
|
||||||
var (
|
var (
|
||||||
domain string
|
domain string
|
||||||
configPath string
|
configPath string
|
||||||
|
publicDirPath string
|
||||||
dev = false
|
dev = false
|
||||||
generateToml bool
|
generateToml bool
|
||||||
generateJson bool
|
generateJson bool
|
||||||
|
@ -33,6 +34,7 @@ var (
|
||||||
func init() {
|
func init() {
|
||||||
flag.StringVar(&domain, "domain", "", "domain to use")
|
flag.StringVar(&domain, "domain", "", "domain to use")
|
||||||
flag.StringVar(&configPath, "config", "", "config to use")
|
flag.StringVar(&configPath, "config", "", "config to use")
|
||||||
|
flag.StringVar(&publicDirPath, "public-dir", "", "public directory to use, default is 'public' inside the folder of your config")
|
||||||
flag.BoolVar(&dev, "dev", dev, "dev mode enabled")
|
flag.BoolVar(&dev, "dev", dev, "dev mode enabled")
|
||||||
flag.BoolVar(&generateJson, "generate-json-config", false, "generate a config example")
|
flag.BoolVar(&generateJson, "generate-json-config", false, "generate a config example")
|
||||||
flag.BoolVar(&generateToml, "generate-toml-config", false, "generate a config example")
|
flag.BoolVar(&generateToml, "generate-toml-config", false, "generate a config example")
|
||||||
|
@ -83,17 +85,22 @@ func main() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
publicFolder := cfg.folder + "public"
|
||||||
|
if len(publicDirPath) != 0 {
|
||||||
|
publicFolder = publicDirPath
|
||||||
|
}
|
||||||
|
|
||||||
var g *golatt.Golatt
|
var g *golatt.Golatt
|
||||||
if dev {
|
if dev {
|
||||||
g = golatt.New(
|
g = golatt.New(
|
||||||
golatt.UsableEmbedFS("templates", templates),
|
golatt.UsableEmbedFS("templates", templates),
|
||||||
os.DirFS(cfg.folder+"public"),
|
os.DirFS(publicFolder),
|
||||||
os.DirFS("dist"),
|
os.DirFS("dist"),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
g = golatt.New(
|
g = golatt.New(
|
||||||
golatt.UsableEmbedFS("templates", templates),
|
golatt.UsableEmbedFS("templates", templates),
|
||||||
os.DirFS(cfg.folder+"public"),
|
os.DirFS(publicFolder),
|
||||||
golatt.UsableEmbedFS("dist", assets),
|
golatt.UsableEmbedFS("dist", assets),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue