fix(parity): restore updated behavior suite compatibility

This commit is contained in:
Micheal Wilkinson
2026-03-21 10:58:15 +00:00
parent abfd6b817b
commit d73049baa4
3 changed files with 82 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
package core
import (
"bufio"
"errors"
"fmt"
"io"
@@ -17,6 +18,7 @@ import (
type App struct {
HomeDir string
ReposDir string
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
Verbose bool
@@ -34,6 +36,7 @@ func New(stdout io.Writer, stderr io.Writer) (*App, error) {
return &App{
HomeDir: home,
ReposDir: filepath.Join(home, ".homesick", "repos"),
Stdin: os.Stdin,
Stdout: stdout,
Stderr: stderr,
}, nil
@@ -173,6 +176,11 @@ func (a *App) PullAll() error {
sort.Strings(castles)
for _, castle := range castles {
if !a.Quiet {
if _, err := fmt.Fprintf(a.Stdout, "%s:\n", castle); err != nil {
return err
}
}
if err := a.runGit(filepath.Join(a.ReposDir, castle), "pull"); err != nil {
return fmt.Errorf("pull --all failed for %q: %w", castle, err)
}
@@ -220,6 +228,16 @@ func (a *App) Destroy(castle string) error {
return err
}
if !a.Force {
confirmed, confirmErr := a.confirmDestroy(castle)
if confirmErr != nil {
return confirmErr
}
if !confirmed {
return nil
}
}
// Only attempt unlinking managed home files for regular castle directories.
if castleInfo.Mode()&os.ModeSymlink == 0 {
castleHome := filepath.Join(castleRoot, "home")
@@ -233,6 +251,25 @@ func (a *App) Destroy(castle string) error {
return os.RemoveAll(castleRoot)
}
func (a *App) confirmDestroy(castle string) (bool, error) {
reader := a.Stdin
if reader == nil {
reader = os.Stdin
}
if _, err := fmt.Fprintf(a.Stdout, "Destroy castle %q? [y/N]: ", castle); err != nil {
return false, err
}
line, err := bufio.NewReader(reader).ReadString('\n')
if err != nil && !errors.Is(err, io.EOF) {
return false, err
}
response := strings.ToLower(strings.TrimSpace(line))
return response == "y" || response == "yes", nil
}
func (a *App) Open(castle string) error {
if strings.TrimSpace(castle) == "" {
castle = "dotfiles"