1
0
Fork 0
This commit is contained in:
Arthur K. 2026-05-14 11:24:48 +03:00
commit 7a6b109e78
Signed by: wzray
GPG key ID: B97F30FDC4636357
4 changed files with 164 additions and 0 deletions

32
cmd/namecount/main.go Normal file
View file

@ -0,0 +1,32 @@
package main
import (
"fmt"
"os"
"tallin/internal/counter"
)
func main() {
if len(os.Args) != 2 {
fmt.Fprintf(os.Stderr, "usage: %s <filename>\n", os.Args[0])
os.Exit(1)
}
file, err := os.Open(os.Args[1])
if err != nil {
fmt.Fprintf(os.Stderr, "open file: %v\n", err)
os.Exit(1)
}
defer file.Close()
counts, err := counter.Count(file)
if err != nil {
fmt.Fprintf(os.Stderr, "read file: %v\n", err)
os.Exit(1)
}
for _, result := range counter.Sorted(counts) {
fmt.Printf("%s:%d\n", result.Name, result.Count)
}
}