Skip to content

Commit

Permalink
fix: reformat status updates to look better
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-j-ibanez committed Feb 25, 2025
1 parent 1a23a9d commit a32c93a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions protocol/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (s SocketHandler) UploadFile(path string) error {
return err
}

fmt.Printf("Sending %s\n", file.Name())
fmt.Printf("Sending \033[1m%s\033[0m\n", file.Name())

if s.Enc == nil {
return errors.New("socket encoder uninitialized")
Expand Down Expand Up @@ -142,7 +142,7 @@ func (s SocketHandler) UploadFile(path string) error {
progress.DisplayProgress()
}

fmt.Println()
fmt.Print("\n\n")
return nil
}

Expand Down Expand Up @@ -171,7 +171,7 @@ func (s *SocketHandler) DownloadFile(path string) error {
return err
}

fmt.Printf("Downloading %s\n", file.Name())
fmt.Printf("Downloading \033[1m%s\033[0m\n", file.Name())

// Write incoming packets to file
progress := status.Progress{
Expand All @@ -195,7 +195,7 @@ func (s *SocketHandler) DownloadFile(path string) error {
progress.DisplayProgress()
}

fmt.Println()
fmt.Print("\n\n")
return nil
}

Expand Down
10 changes: 6 additions & 4 deletions status/loadingbar.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ func (p *Progress) getLoadingBar() string {
p.UpdateProgressPercent()

bar := ""
bar += "["
bar += strings.Repeat("-", int(p.Percentage/5))
bar += ""
bar += "\033[32m"
bar += strings.Repeat("━", int(p.Percentage/5))
bar += strings.Repeat(" ", 20-int(p.Percentage/5))
bar += "]"
bar += "\033[0m"
bar += ""

return bar
}

func (p *Progress) DisplayProgress() {
progressBar := "\r[%3d%%] "
progressBar := "\r%3d%% "
progressBar += p.getLoadingBar()
progressBar += " " + p.getTimeElapsed()
fmt.Printf(progressBar, p.Percentage)
Expand Down

0 comments on commit a32c93a

Please sign in to comment.