Skip to content

Commit

Permalink
Spinner revamp (#146)
Browse files Browse the repository at this point in the history
* Fixing spinner

* Temporary unblocker for high priority fix

* trying to fix broken pipe tests
  • Loading branch information
Melkeydev authored Nov 28, 2023
1 parent f8218ce commit fd40e22
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/generate-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ jobs:
matrix:
framework:
[chi, gin, fiber, gorilla/mux, httprouter, standard-library, echo]
driver:
[mysql, postgres, sqlite, mongo, none]
driver: [mysql, postgres, sqlite, mongo, none]
goVersion: ["1.20"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: build templates
run: go run main.go create -n ${{ matrix.framework }} -f ${{ matrix.framework}} -d ${{ matrix.driver }}
run: script -q /dev/null -c "go run main.go create -n ${{ matrix.framework }} -f ${{ matrix.framework}} -d ${{matrix.driver}}" /dev/null
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
Expand Down
15 changes: 7 additions & 8 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,23 +155,22 @@ var createCmd = &cobra.Command{
}
project.AbsolutePath = currentWorkingDir
spinner := tea.NewProgram(spinner.InitialModelNew())

// add synchronization to wait for spinner to finish
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
defer wg.Done()
// only run the spinner if the command is interactive
if isInteractive {
if _, err := spinner.Run(); err != nil {
cobra.CheckErr(err)
}
if _, err := spinner.Run(); err != nil {
cobra.CheckErr(err)
}
}()

err = project.CreateMainFile()

// once the create is done, stop the spinner
if isInteractive {
spinner.Quit()
}
spinner.Quit()

// wait for the spinner to finish
wg.Wait()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/ui/spinner/spinner.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (m model) View() string {
if m.err != nil {
return m.err.Error()
}
str := fmt.Sprintf("\n\n %s Preparing...\n\n", m.spinner.View())
str := fmt.Sprintf("%s Preparing...", m.spinner.View())
if m.quitting {
return str + "\n"
}
Expand Down

0 comments on commit fd40e22

Please sign in to comment.