Skip to content

Commit 52dada3

Browse files
authored
[stepper] respect the io.Writer used in impl/devbox.go (#507)
## Summary I noticed the stepper wasn't respecting the `io.Writer` used in the `impl/devbox.go` and `cloud/cloud.go` apis. Hooked it up. ## How was it tested? Ran `devbox shell` and `devbox cloud shell` and got expected output.
1 parent 0db3480 commit 52dada3

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

internal/cloud/cloud.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func Shell(w io.Writer, projectDir string, githubUsername string) error {
7373
}
7474

7575
if vmHostname == "" {
76-
stepVM := stepper.Start("Creating a virtual machine on the cloud...")
76+
stepVM := stepper.Start(w, "Creating a virtual machine on the cloud...")
7777
// Inspect the ssh ControlPath to check for existing connections
7878
vmHostname = vmHostnameFromSSHControlPath()
7979
if vmHostname != "" {
@@ -98,15 +98,15 @@ func Shell(w io.Writer, projectDir string, githubUsername string) error {
9898
}
9999
debug.Log("vm_hostname: %s", vmHostname)
100100

101-
s2 := stepper.Start("Starting file syncing...")
101+
s2 := stepper.Start(w, "Starting file syncing...")
102102
err = syncFiles(username, vmHostname, projectDir)
103103
if err != nil {
104104
s2.Fail("Starting file syncing [FAILED]")
105105
return err
106106
}
107107
s2.Success("File syncing started")
108108

109-
s3 := stepper.Start("Connecting to virtual machine...")
109+
s3 := stepper.Start(w, "Connecting to virtual machine...")
110110
time.Sleep(1 * time.Second)
111111
s3.Stop("Connecting to virtual machine")
112112
fmt.Fprint(w, "\n")

internal/impl/devbox.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ func (d *Devbox) installNixProfile() (err error) {
703703
msg = fmt.Sprintf("[%d/%d] %s", stepNum, total, pkg)
704704
}
705705

706-
step := stepper.Start(msg)
706+
step := stepper.Start(d.writer, msg)
707707

708708
// TODO savil. hook this up to gcurtis's mirrorURL
709709
nixPkgsURL := fmt.Sprintf("https://github.com/nixos/nixpkgs/archive/%s.tar.gz", d.cfg.Nixpkgs.Commit)

internal/ux/stepper/stepper.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package stepper
55

66
import (
77
"fmt"
8+
"io"
89
"time"
910

1011
"github.com/briandowns/spinner"
@@ -15,8 +16,8 @@ type Stepper struct {
1516
spinner *spinner.Spinner
1617
}
1718

18-
func Start(format string, a ...any) *Stepper {
19-
spinner := spinner.New(spinner.CharSets[11], 100*time.Millisecond)
19+
func Start(w io.Writer, format string, a ...any) *Stepper {
20+
spinner := spinner.New(spinner.CharSets[11], 100*time.Millisecond, spinner.WithWriter(w))
2021
err := spinner.Color("magenta")
2122
if err != nil {
2223
panic(err)

0 commit comments

Comments
 (0)