Flag to set a custom project path.

This commit is contained in:
2024-09-12 00:18:40 +02:00
parent d0b4b99cd9
commit db20d07245
4 changed files with 61 additions and 18 deletions

View File

@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
"slices"
"strings"
"gitea.codeblob.work/pk/hoster/internals/conf"
"gitea.codeblob.work/pk/hoster/internals/helpers"
@ -18,8 +19,9 @@ import (
)
func CmdNew(c *cli.Context) error {
name := c.String("name")
domain := c.String("domain")
name := strings.TrimSpace(c.String("name"))
domain := strings.TrimSpace(c.String("domain"))
customProjectPath := strings.TrimSpace(c.String("project-path"))
projectRoot := conf.App.MustString("projects.root")
sitesAvail := conf.App.MustString("nginx.sitesAvailable")
sitesEnabled := conf.App.MustString("nginx.sitesEnabled")
@ -27,6 +29,10 @@ func CmdNew(c *cli.Context) error {
projectFolder := filepath.Join(projectRoot, name)
if customProjectPath == "" {
projectFolder = customProjectPath
}
existingProjects, err := helpers.FindHostConfigs(sitesAvail)
if err != nil {
return err