package main import ( "fmt" "log" "hosts-go/internal/core" ) func main() { fmt.Println("hosts-go - Foundation Implementation") fmt.Println("===================================") // Create a new hosts file hostsFile := core.NewHostsFile() // Add some example entries to demonstrate the foundation entry1, err := core.NewHostEntry("127.0.0.1", "localhost") if err != nil { log.Fatalf("Failed to create entry: %v", err) } entry1.Comment = "Local loopback" entry2, err := core.NewHostEntry("192.168.1.100", "dev.example.com") if err != nil { log.Fatalf("Failed to create entry: %v", err) } entry2.AddAlias("www.dev.example.com") entry2.AddAlias("api.dev.example.com") entry2.Comment = "Development server" entry3, err := core.NewHostEntry("10.0.0.50", "staging.example.com") if err != nil { log.Fatalf("Failed to create entry: %v", err) } entry3.Active = false // Inactive entry entry3.Comment = "Staging server (disabled)" // Add entries to hosts file hostsFile.AddEntry(entry1) hostsFile.AddEntry(entry2) hostsFile.AddEntry(entry3) // Demonstrate the foundation functionality fmt.Printf("Total entries: %d\n", len(hostsFile.Entries)) fmt.Printf("Active entries: %d\n", len(hostsFile.ActiveEntries())) fmt.Println() fmt.Println("All entries:") for i, entry := range hostsFile.Entries { fmt.Printf("%d. %s\n", i+1, entry.String()) } fmt.Println() fmt.Println("Active entries only:") for i, entry := range hostsFile.ActiveEntries() { fmt.Printf("%d. %s\n", i+1, entry.String()) } fmt.Println() // Demonstrate search functionality fmt.Println("Search demonstrations:") if found := hostsFile.FindEntry("localhost"); found != nil { fmt.Printf("Found 'localhost': %s\n", found.String()) } if found := hostsFile.FindEntry("www.dev.example.com"); found != nil { fmt.Printf("Found 'www.dev.example.com' (alias): %s\n", found.String()) } if found := hostsFile.FindEntry("notfound.com"); found == nil { fmt.Println("'notfound.com' not found (as expected)") } fmt.Println() fmt.Println("Foundation implementation complete!") fmt.Println("✅ Core data models working") fmt.Println("✅ Validation system working") fmt.Println("✅ Host entry management working") fmt.Println("✅ Search and filtering working") fmt.Println() fmt.Println("Next steps: Implement hosts file parser and TUI components") }