fix: host lookup by hostname, interactive input with spaces

This commit is contained in:
swanadiva
2026-06-23 14:16:49 +07:00
parent 48c858df0f
commit 1869cff590
2 changed files with 32 additions and 31 deletions
+14
View File
@@ -103,6 +103,20 @@ func findHost(ctx context.Context, store storage.Storage, identifier string) (*m
}
}
// Try to find by hostname
for _, h := range hosts {
if h.Hostname == identifier {
return h, nil
}
}
// Try to find by ID prefix (short ID match)
for _, h := range hosts {
if len(h.ID) >= 8 && h.ID[:8] == identifier {
return h, nil
}
}
// Host not found, provide helpful error
return nil, fmt.Errorf("host '%s' not found. Use 'hostkeeper list' to see available hosts", identifier)
}