-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
60 lines (56 loc) · 1.55 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
package main
import (
"os"
"snap/internal/argparser"
"snap/internal/check"
"snap/internal/initialize"
"snap/internal/logger"
"snap/internal/restore"
"snap/internal/settings"
"snap/internal/snapshot"
"snap/internal/status"
)
func main() {
logger.Trace("main", "")
// parse args
args := os.Args
argparser.Create(args[1:])
if len(args) > 1 {
cmd := args[1]
if cmd == "init" {
initialize.Execute()
} else {
settings.Load()
if cmd == "pull" {
restore.Execute()
} else if cmd == "list" {
status.Execute()
} else if cmd == "check" {
check.Execute()
} else if cmd == "shot" {
snapshot.Execute()
} else {
logger.Error("main", cmd,
"Unknown argument.\n"+
"Please use one of the init, pull, shot, list commands.")
}
}
} else {
if settings.Exists() {
logger.Error("main", "",
"No argument.\n"+
"\nPlease specify one of the following commands, all of them are safe to run.\n"+
"pull, shot, list")
} else {
logger.Error("main", "",
"Not initialized as a project root.\n"+
"\nPlease run 'init' with a rootname (a name for the current project directory),\n"+
"and a path to a remote folder to backup to, or restore from.\n\n"+
"Make sure your rootname is future-proof. Each remote can contain multiple roots.\n"+
"Once you initialized, you will be able to take a snapshot of the current directory,\n"+
"or view a list of snapshots if you have an existing remote and restore them.\n"+
"\nUSAGE: init <rootname> <remote folder path>\n")
}
}
logger.Print("~")
}