mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-06 16:40:32 +00:00
42 lines
744 B
Go
42 lines
744 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, for example: gopeed https://www.google.com or gopeed bt.torrent or gopeed magnet:?xt=urn:btih:...")
|
|
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")
|
|
}
|