sort-cli: rework

This commit is contained in:
2024-01-29 14:06:41 +03:00
parent a17d379bd1
commit 380099b9b3
6 changed files with 253 additions and 192 deletions

26
sort-cli/config.go Normal file
View File

@ -0,0 +1,26 @@
package main
import "flag"
type Config struct {
Key int
Numeric bool
Reverse bool
Unique bool
Sources []string
}
func (c *Config) ParseFlags() {
flag.IntVar(&c.Key, "k", 0, "sort via column")
flag.BoolVar(&c.Numeric, "n", false, "compare according to string numerical value")
flag.BoolVar(&c.Reverse, "r", false, "reverse the result of comparisons")
flag.BoolVar(&c.Unique, "u", false, "output only the first of an equal run")
flag.Parse()
c.Sources = flag.Args()
if len(c.Sources) == 0 {
c.Sources = []string{"-"}
}
}