package main import "flag" const stdin = "-" 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{stdin} } }