-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
44 lines (33 loc) · 920 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"flag"
"os"
"strconv"
"strings"
"github.com/lmortezal/GoConnect/connect"
)
func main() {
var (
destination string
source string
port uint
)
dir , _ := os.Getwd()
flag.StringVar(&destination, "d", dir , "destination directory (e.g. /home/user/GoConnect )")
flag.StringVar(&source, "s", "" , "source directory (e.g. user@golang:/home/target/GoConnect )")
flag.UintVar(&port, "p", 22 , "port number")
flag.Parse()
flag.Func("help", "show help" , func(s string) error { flag.PrintDefaults(); return nil })
if len(os.Args) == 1{
flag.PrintDefaults()
return
}else if source == "" {
flag.PrintDefaults()
return
}
var sources [3]string
sources[0] = strings.Split(source , "@")[0]
sources[2] = strings.Split(source , ":")[1]
sources[1] = strings.Split(strings.Split(source, "@")[1],":")[0]
connect.Initailize(destination , strconv.Itoa(int(port)) , sources)
}