func main() { if len(os.Args) == 1 { usage() } parse: for { switch g.Getopt("d:") { case g.EOF: break parse case 'd': Flagd = g.Optarg default: usage() } } if len(os.Args[g.Optind:]) == 0 { usage() } for _, n := range os.Args[g.Optind:] { os.Stdout.WriteString(Cleanname(n) + "\n") } os.Exit(0) }
func main() { suffix := "" parse: for { switch g.Getopt("d") { case g.EOF: break parse case 'd': Flagd = true default: usage() } } switch len(os.Args[g.Optind:]) { case 2: suffix = os.Args[g.Optind+1] fallthrough case 1: os.Stdout.WriteString(Basename(os.Args[g.Optind], suffix) + "\n") default: usage() } os.Exit(0) }