Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #33 from albertdev/bugfix/platform-indedependent-h…
Browse files Browse the repository at this point in the history
…omedir

Use platform independent os.UserHomeDir() function
  • Loading branch information
FooSoft authored Dec 14, 2021
2 parents ddbd7c4 + 8d703e9 commit 72ff784
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion homemaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"log"
"os"
"path"
"strings"
)

const (
Expand All @@ -50,7 +51,7 @@ func usage() {

func main() {
taskName := flag.String("task", "default", "name of task to execute")
dstDir := flag.String("dest", os.Getenv("HOME"), "target directory for tasks")
dstDir := flag.String("dest", "", "target directory for tasks")
force := flag.Bool("force", true, "create parent directories to target")
clobber := flag.Bool("clobber", false, "delete files and directories at target")
verbose := flag.Bool("verbose", false, "verbose output")
Expand Down Expand Up @@ -94,6 +95,10 @@ func main() {
log.Fatal(err)
}

if strings.TrimSpace(*dstDir) == "" {
*dstDir, _ = os.UserHomeDir()
}

conf.srcDir = makeAbsPath(flag.Arg(1))
conf.dstDir = makeAbsPath(*dstDir)
conf.variant = *variant
Expand Down

0 comments on commit 72ff784

Please sign in to comment.