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.`,
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 {