done
This commit is contained in:
36
cmd/find.go
36
cmd/find.go
@@ -33,21 +33,21 @@ This command will:
|
||||
|
||||
func runFind(cmd *cobra.Command, args []string) error {
|
||||
// Detect distribution
|
||||
fmt.Println(color.CyanString("🔍 Detecting your Linux distribution..."))
|
||||
fmt.Println(color.CyanString("Detecting your Linux distribution..."))
|
||||
|
||||
distroInfo, err := distro.DetectDistribution()
|
||||
if err != nil {
|
||||
return fmt.Errorf("fuck me, couldn't detect your distro: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("📦 Found: %s\n", color.GreenString(distroInfo.String()))
|
||||
fmt.Printf("Found: %s\n", color.GreenString(distroInfo.String()))
|
||||
|
||||
if !distroInfo.IsSupported() {
|
||||
return fmt.Errorf("sorry, %s isn't supported yet - but hey, you're using something exotic! 🦄", distroInfo.ID)
|
||||
}
|
||||
|
||||
// Get mirrors for this distribution family
|
||||
fmt.Printf("🔧 Loading mirrors for %s family...\n", color.YellowString(distroInfo.Family))
|
||||
fmt.Printf("Loading mirrors for %s family...\n", color.YellowString(distroInfo.Family))
|
||||
|
||||
mirrorList := mirror.NewMirrorList(distroInfo.Family)
|
||||
|
||||
@@ -60,8 +60,7 @@ func runFind(cmd *cobra.Command, args []string) error {
|
||||
return fmt.Errorf("failed to load mirrors: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("⚡ Testing %d mirrors (timeout: %ds each)...\n",
|
||||
len(mirrorList.Mirrors), timeout)
|
||||
fmt.Printf("Testing mirrors (timeout: %ds each)...\n", timeout)
|
||||
|
||||
err = mirrorList.TestMirrors(ctx, time.Duration(timeout)*time.Second)
|
||||
|
||||
@@ -70,7 +69,7 @@ func runFind(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
// Display results
|
||||
fmt.Println("\n" + color.GreenString("🎉 Testing complete! Here are your results:"))
|
||||
fmt.Println("\n" + color.GreenString("Testing complete! Here are your results:"))
|
||||
fmt.Println()
|
||||
|
||||
topMirrors := mirrorList.GetTop(topCount)
|
||||
@@ -85,11 +84,11 @@ func runFind(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if verbose {
|
||||
fmt.Printf("📊 Test Summary: %d/%d mirrors responded successfully\n", successCount, len(allMirrors))
|
||||
fmt.Printf("Test Summary: %d/%d mirrors responded successfully\n", successCount, len(allMirrors))
|
||||
fmt.Println()
|
||||
}
|
||||
if len(topMirrors) == 0 {
|
||||
fmt.Println(color.RedString("😱 No working mirrors found. Your internet might be fucked, or all mirrors are down."))
|
||||
fmt.Println(color.RedString("No working mirrors found. Your internet might be fucked, or all mirrors are down."))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -132,32 +131,29 @@ func runFind(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println()
|
||||
best := mirrorList.GetBest()
|
||||
if best != nil {
|
||||
fmt.Printf("🏆 Winner: %s\n", color.GreenString(best.URL))
|
||||
fmt.Printf("⚡ This bad boy clocks in at %.1f MB/s with %dms latency\n",
|
||||
fmt.Printf("Winner: %s\n", color.GreenString(best.URL))
|
||||
fmt.Printf("This bad boy clocks in at %.1f MB/s with %dms latency\n",
|
||||
best.Speed, best.Latency.Milliseconds())
|
||||
}
|
||||
|
||||
// Show failed mirrors in verbose mode
|
||||
// Show failed mirror count in verbose mode (no detailed errors)
|
||||
if verbose {
|
||||
failedMirrors := make([]mirror.Mirror, 0)
|
||||
failedCount := 0
|
||||
for _, m := range allMirrors {
|
||||
if m.Error != nil {
|
||||
failedMirrors = append(failedMirrors, m)
|
||||
failedCount++
|
||||
}
|
||||
}
|
||||
|
||||
if len(failedMirrors) > 0 {
|
||||
if failedCount > 0 {
|
||||
fmt.Println()
|
||||
fmt.Printf("❌ Failed mirrors (%d):\n", len(failedMirrors))
|
||||
for _, m := range failedMirrors {
|
||||
fmt.Printf(" %s - %s\n", color.RedString(m.URL), m.Error.Error())
|
||||
}
|
||||
fmt.Printf("Failed mirrors: %d (errors hidden for cleaner output)\n", failedCount)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
fmt.Printf("💡 To apply the fastest mirror, run: %s\n",
|
||||
color.YellowString("fastestmirror apply"))
|
||||
fmt.Printf("To apply the fastest mirror, run: %s\n",
|
||||
color.CyanString("fastestmirror apply"))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user