diff --git a/commands/commands.go b/commands/commands.go index 4bd855a..e0f85da 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -2,6 +2,7 @@ package commands import ( "fmt" + "path/filepath" "github.com/facundoolano/blorg/site" ) @@ -30,12 +31,15 @@ func New() error { } // Read the files in src/ render them and copy the result to target/ -// TODO add root dir override support -func Build() error { - site, err := site.Load(SRC_DIR, LAYOUTS_DIR) +func Build(root string) error { + src := filepath.Join(root, SRC_DIR) + target := filepath.Join(root, TARGET_DIR) + layouts := filepath.Join(root, LAYOUTS_DIR) + + site, err := site.Load(src, layouts) if err != nil { return err } - return site.Build(SRC_DIR, TARGET_DIR, true, false) + return site.Build(src, target, true, false) } diff --git a/main.go b/main.go index fbe53ff..7082c10 100644 --- a/main.go +++ b/main.go @@ -34,7 +34,11 @@ func run(args []string) error { initCmd.Parse(os.Args[2:]) return commands.Init() case "build": - return commands.Build() + rootDir := "." + if len(os.Args) > 2 { + rootDir = os.Args[2] + } + return commands.Build(rootDir) case "new": newCmd.Parse(os.Args[2:]) return commands.New()