sort-cli: rework
This commit is contained in:
26
sort-cli/config.go
Normal file
26
sort-cli/config.go
Normal 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{"-"}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user