feat(init): Continue Init with directory creation

This commit is contained in:
Matthieu 'JP' DERASSE
2022-08-02 20:30:46 +00:00
parent cc0e94690e
commit 5434cc15ce
6 changed files with 37 additions and 11 deletions

View File

@ -6,6 +6,7 @@ package cmd
import (
"os"
"path/filepath"
"strings"
"github.com/juju/errors"
@ -140,9 +141,32 @@ func runInitAction(cmd *cobra.Command, args []string) {
return
}
projectDirPath := filepath.Join(currentPath, userInput.ProjectDirectory)
log.Debugf("Our project directory path is: %s", projectDirPath)
// create project directory
log.Debug("Creating project directory")
dirCreated, err := helpers.CheckAndCreateDir(projectDirPath)
if err != nil {
log.Errorf("Fail to create project directory. The following error happen: %s", err.Error())
return
}
if !dirCreated {
log.Error("A directory already exist with your project directory name")
return
}
// move to project directory
err = os.Chdir(projectDirPath)
if err != nil {
log.Errorf("Fail to move to project directory. The following error happen: %s", err.Error())
return
}
// XXX:
// Create directory
// Move to dir
// git init
// create .gouick
// move templated file

View File

@ -89,7 +89,7 @@ func runUpgradeAction(cmd *cobra.Command, args []string) {
log.Debug("Checking directory and creating it if needed")
// check if the path is ok, else ask user for new path if we are in a interactive mode, else stop
err = helpers.CheckAndCreateDir(installDirectory)
_, err = helpers.CheckAndCreateDir(installDirectory)
if err != nil {
log.Errorf("Impossible to create the instalation directory for %s", dependency.GetName())
if acceptAll {