Ztorrent/ui/window.go
itexpert228 cf79db0932 huy
2026-03-06 12:02:52 +03:00

42 lines
1 KiB
Go

package ui
import (
"fmt"
"os"
"github.com/veggiedefender/torrent-client/internal/app"
)
func Start(controller *app.Controller) {
fmt.Println("Ztorrent")
if len(os.Args) < 2 {
fmt.Println("Usage: torrent-client <path-to-torrent-file>")
return
}
path := os.Args[1]
if err := controller.StartTorrent(path); err != nil {
fmt.Printf("Warning: tracker announce failed: %v\n", err)
}
status := controller.Status()
if !status.Loaded {
fmt.Println("No torrent metadata loaded.")
return
}
fmt.Printf("Name: %s\n", status.Name)
fmt.Printf("Size: %d bytes\n", status.Length)
fmt.Printf("Piece length: %d bytes\n", status.PieceLength)
fmt.Printf("Pieces: %d\n", status.PieceCount)
fmt.Printf("Files: %d\n", len(status.Files))
for _, file := range status.Files {
fmt.Printf(" - %s (%d bytes)\n", file.Path, file.Length)
}
fmt.Printf("Tracker: %s\n", status.Announce)
fmt.Printf("Peers: %d\n", status.PeerCount)
if status.LastError != "" {
fmt.Printf("Last error: %s\n", status.LastError)
}
}