cmd: Fix incorrect initialzation by cobra init .

Close #314
This commit is contained in:
Albert Nigmatzianov 2017-05-05 10:51:57 +02:00
parent 7bd35d3b95
commit db6b9a8b3f

View file

@ -40,15 +40,19 @@ and the appropriate structure for a Cobra-based CLI application.
Init will not use an existing directory with contents.`, Init will not use an existing directory with contents.`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
wd, err := os.Getwd()
if err != nil {
er(err)
}
var project *Project var project *Project
if len(args) == 0 { if len(args) == 0 {
wd, err := os.Getwd()
if err != nil {
er(err)
}
project = NewProjectFromPath(wd) project = NewProjectFromPath(wd)
} else if len(args) == 1 { } else if len(args) == 1 {
arg := args[0] arg := args[0]
if arg[0] == '.' {
arg = filepath.Join(wd, arg)
}
if filepath.IsAbs(arg) { if filepath.IsAbs(arg) {
project = NewProjectFromPath(arg) project = NewProjectFromPath(arg)
} else { } else {