diff --git a/internal/cli/doctor.go b/internal/cli/doctor.go index 33911ad..6ddfd1b 100644 --- a/internal/cli/doctor.go +++ b/internal/cli/doctor.go @@ -39,7 +39,11 @@ func Doctor(w io.Writer) int { engineName = engine.Name host := engine.Host if host == "" { - host = i18n.T("doctor.hostDefault") + if env := os.Getenv("DOCKER_HOST"); env != "" { + host = env + } else { + host = i18n.T("doctor.hostDefault") + } } if info, err := cl.Info(ctx); err != nil { fmt.Fprintf(w, "engine : %s %s %v\n", i18n.T("error.warn"), engine.Name, err) diff --git a/internal/docker/compose.go b/internal/docker/compose.go index b06f338..298ec96 100644 --- a/internal/docker/compose.go +++ b/internal/docker/compose.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "os/exec" + "regexp" "strings" ) @@ -85,14 +86,26 @@ func (c *ComposeClient) List(ctx context.Context) ([]ComposeProject, error) { } // Version — versi compose ringkas (mis. "5.6.0"). +// Provider (mis. `podman compose` → docker-compose) kadang menulis pesan +// peringatan ke output; ambil baris terakhir non-kosong & bersihkan ANSI. func (c *ComposeClient) Version(ctx context.Context) (string, error) { out, err := c.Run(ctx, "", "version", "--short") if err != nil { return "", err } - return strings.TrimSpace(out), nil + lines := strings.Split(out, "\n") + for i := len(lines) - 1; i >= 0; i-- { + if l := stripANSI(strings.TrimSpace(lines[i])); l != "" { + return l, nil + } + } + return "", nil } +var ansiRE = regexp.MustCompile(`\x1b\[[0-9;?<>=]*[A-Za-z]`) + +func stripANSI(s string) string { return ansiRE.ReplaceAllString(s, "") } + // --- operasi stack (dipakai manager & CLI companion) --- func (c *ComposeClient) Up(ctx context.Context, dir string) (string, error) {