From db6b9a8b3f3f400c8ecb4a4d7d02245b8facad66 Mon Sep 17 00:00:00 2001 From: Albert Nigmatzianov Date: Fri, 5 May 2017 10:51:57 +0200 Subject: [PATCH] cmd: Fix incorrect initialzation by `cobra init .` Close #314 --- cobra/cmd/init.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cobra/cmd/init.go b/cobra/cmd/init.go index 7812d9cb..788bdb56 100644 --- a/cobra/cmd/init.go +++ b/cobra/cmd/init.go @@ -40,15 +40,19 @@ and the appropriate structure for a Cobra-based CLI application. Init will not use an existing directory with contents.`, Run: func(cmd *cobra.Command, args []string) { + wd, err := os.Getwd() + if err != nil { + er(err) + } + var project *Project if len(args) == 0 { - wd, err := os.Getwd() - if err != nil { - er(err) - } project = NewProjectFromPath(wd) } else if len(args) == 1 { arg := args[0] + if arg[0] == '.' { + arg = filepath.Join(wd, arg) + } if filepath.IsAbs(arg) { project = NewProjectFromPath(arg) } else {