Skip to content

Commit

Permalink
feat: add spinner while fetching template
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickMenoti committed Nov 4, 2024
1 parent 6cffa72 commit 847429b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion messages/init/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var (
EdgeApplicationsInitFlagYes = "Answers all yes/no interactions automatically with yes"
EdgeApplicationsInitFlagNo = "Answers all yes/no interactions automatically with no"
WebAppInitContentOverridden = "This application was already configured. Do you want to override the previous configuration? <yes | no> (default: no) "
WebAppInitCmdSuccess = "Template successfully fetched and configured\n"
WebAppInitCmdSuccess = "Template successfully configured\n"
InitGettingTemplates = "\nGetting presets available (Some dependencies may need to be installed)\n"
InitGettingVulcan = "\nGetting templates available\n"
InitProjectQuestion = "Your application's name: "
Expand Down
11 changes: 11 additions & 0 deletions pkg/cmd/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"path"
"strings"
"time"

"github.com/AlecAivazis/survey/v2"
"github.com/MakeNowJust/heredoc"
Expand All @@ -25,6 +26,7 @@ import (
vulcanPkg "github.com/aziontech/azion-cli/pkg/vulcan"
"github.com/aziontech/azion-cli/utils"
thoth "github.com/aziontech/go-thoth"
"github.com/briandowns/spinner"
"github.com/go-git/go-git/v5"
"github.com/joho/godotenv"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -230,12 +232,21 @@ func (cmd *initCmd) Run(c *cobra.Command, _ []string) error {
}
}()

s := spinner.New(spinner.CharSets[7], 100*time.Millisecond)
s.Suffix = " Fetching selected template..."
s.FinalMSG = "Template successfully fetched\n"
if !cmd.f.Debug {
s.Start() // Start the spinner
}

err = cmd.git.Clone(SAMPLESURL, tempDir)
if err != nil {
logger.Debug("Error while cloning the repository", zap.Error(err))
return err
}

s.Stop()

oldPath := path.Join(tempDir, "templates", templateOptionsMap[answerTemplate].Path)
newPath := path.Join(pathWorkingDirHere, cmd.name)

Expand Down

0 comments on commit 847429b

Please sign in to comment.