Skip to content

Commit

Permalink
refactor: clean up sync progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkato committed Mar 22, 2024
1 parent 02a4430 commit f001170
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions cmd/vale/command.go
Expand Up @@ -103,24 +103,25 @@ func sync(_ []string, flags *core.CLIFlags) error {
}
stylesPath := cfg.StylesPath()

title := fmt.Sprintf("Syncing %d package(s) to '%s'", len(pkgs), stylesPath)
p, err := pterm.DefaultProgressbar.WithTotal(
len(pkgs)).WithTitle(title).Start()

p, err := pterm.DefaultProgressbar.WithTotal(len(pkgs)).Start()
if err != nil {
return err
}

for idx, pkg := range pkgs {
if err = readPkg(pkg, stylesPath, idx); err != nil {
return err
}
name := fileNameWithoutExt(pkg)

pterm.Success.Println("Downloaded package '" + name + "'")
p.UpdateTitle("Syncing " + name)
p.Increment()

if err = readPkg(pkg, stylesPath, idx); err != nil {
return err
}
}

msg := fmt.Sprintf("Synced %d package(s) to '%s'.", len(pkgs), stylesPath)
pterm.Success.Println(msg)

return nil
}

Expand Down

0 comments on commit f001170

Please sign in to comment.