-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
69 lines (63 loc) · 1.68 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"flag"
"fmt"
)
const (
// VERSION of package
VERSION = "VERSION\n" +
"\t 0.1.0\n\n"
// DESCRIPTION what is package for
DESCRIPTION = "DESCRIPTION\n" +
"\tSync your data with cloud storages (like Amazon S3, Rackspace CloudFiles etc.)\n\n"
// COMMANDS lists commands available
COMMANDS = "COMMANDS\n" +
"\tinit\tinitialize .cloudcore and .cloud files\n" +
"\tsync\tsynchronize folder with the cloud\n" +
"\tupdate\tupdate file or folder in container\n" +
"\turl\tshow container url\n" +
"\tignore\tignore particular file with .cloudignore\n" +
"\tclear\tclear container\n" +
"\thelp\tshow this message\n\n"
// CONTRIBUTORS shows package author & contributors
CONTRIBUTORS = "CONTRIBUTORS\n" +
"\tOlexandr Shalakhin <[email protected]>\n\n"
)
// usage is responsible to generate command help message
func usage() {
fmt.Printf(DESCRIPTION + VERSION + COMMANDS + CONTRIBUTORS)
flag.PrintDefaults()
}
// getContainerName if it is presented in args as a second parameter
func getContainerName(args []string) string {
// default container is the first in .cloud
container := ""
if len(args) > 2 {
// use defined
container = args[1]
}
return container
}
func main() {
flag.Usage = usage
flag.Parse()
args := flag.Args()
switch {
case args[0] == "init":
initConfigs()
case args[0] == "sync":
Sync(getContainerName(args))
// case args[0] == "update":
// Update(, getContainerName(args))
case args[0] == "url":
GetContainerURL(getContainerName(args))
case args[0] == "ignore":
fmt.Println("Nothing here yet...")
case args[0] == "clear":
fmt.Println("Nothing here yet...")
case args[0] == "help":
usage()
default:
usage()
}
}