func main() { flag.Parse() cli.RequireArgs(2, "You must provide 2 distinct numbers as arguments to the program") args := cli.IntsArgs() fmt.Println("Greatest common divisor is", Gcd(args[0], args[1])) }
func main() { alg := cli.AlgorithmFlag(availableAlgs, "eratosphen_sieve") args := cli.IntsArgs() f := availableAlgs[alg] fmt.Println("Algorithm:", alg) f(args) }
func main() { alg := cli.AlgorithmFlag(availableAlgs, "merge") cli.RequireSortingArgs() list := cli.IntsArgs() f := availableAlgs[alg] f(list) fmt.Println("Algorithm:", alg) fmt.Println("Sorted list:", list) }