Files
gopeed/cmd/gopeed/flags.go
T
2022-11-05 10:43:07 +08:00

42 lines
645 B
Go

package main
import (
"flag"
"fmt"
"os"
)
type args struct {
url string
connections *int
dir *string
}
func parse() *args {
dir, err := os.Getwd()
if err != nil {
panic(err)
}
var args args
args.connections = flag.Int("C", 16, "Concurrent connections.")
args.dir = flag.String("D", dir, "Store directory.")
flag.Parse()
t := flag.Args()
if len(t) > 0 {
args.url = t[0]
} else {
gPrintln("missing url parameter")
gPrintln("try 'gopeed -h' for more information")
os.Exit(1)
}
return &args
}
func gPrint(msg string) {
fmt.Print("gopeed: " + msg)
}
func gPrintln(msg string) {
gPrint(msg + "\n")
}