From 4c53c57d5eecd32e746bfc4479d7a93923f7213a Mon Sep 17 00:00:00 2001 From: Matthieu 'JP' DERASSE Date: Wed, 3 Aug 2022 19:59:33 +0000 Subject: [PATCH] feat(init): Add some logs and initialize git --- cmd/init.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/cmd/init.go b/cmd/init.go index b518075..79c7c5d 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -6,6 +6,7 @@ package cmd import ( "os" + "os/exec" "path/filepath" "strings" @@ -145,7 +146,7 @@ func runInitAction(cmd *cobra.Command, args []string) { log.Debugf("Our project directory path is: %s", projectDirPath) // create project directory - log.Debug("Creating project directory") + log.Infof("Creating project directory") dirCreated, err := helpers.CheckAndCreateDir(projectDirPath) if err != nil { @@ -158,15 +159,26 @@ func runInitAction(cmd *cobra.Command, args []string) { return } - // move to project directory + // Move to project directory. + log.Infof("Moving to the project directory: %s", userInput.ProjectDirectory) + err = os.Chdir(projectDirPath) if err != nil { log.Errorf("Fail to move to project directory. The following error happen: %s", err.Error()) return } - // XXX: - // git init - // create .gouick - // move templated file + // Execute git init. + log.Info("Initializing Git") + + gitinit := exec.Command("git", "init") + _, err = gitinit.Output() + if err != nil { + log.Errorf("Fail to git init. The following error happen: %s", err.Error()) + return + } + + log.Info("Creating gouick configuration file") + + log.Info("Creating API skeleton") }