-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
64 lines (56 loc) · 1.38 KB
/
main.go
File metadata and controls
64 lines (56 loc) · 1.38 KB
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
package main
import (
"flag"
"fmt"
"os"
)
const (
NAME string = "MEncFS"
DESCRIPTION string = "Manage EncFS"
VERSION string = "0.8.1"
)
func usage() {
fmt.Fprintf(os.Stderr, "%s - %s %s\n\n", NAME, DESCRIPTION, VERSION)
fmt.Fprintf(os.Stderr, "usage: %s [arguments ..] [action] [path ..]\n\n", NAME)
fmt.Fprintf(os.Stderr, "arguments:\n")
fmt.Fprintf(os.Stderr, " --force\tForce action\n")
fmt.Fprintf(os.Stderr, "\nactions:\n")
fmt.Fprintf(os.Stderr, " encrypt\tEncrypt a folder\n")
fmt.Fprintf(os.Stderr, " mount\t\tMount Volumes as defined in the config file\n")
fmt.Fprintf(os.Stderr, " umount\tUnmount Volumes defined in the config file\n")
fmt.Fprintf(os.Stderr, " generate\tGenerate config file %s\n", GetConfigFilePath())
fmt.Fprintf(os.Stderr, " automount\tToggle automounting of Volumes when the computer starts\n")
os.Exit(2)
}
func main() {
var (
action string = ""
err error = nil
)
force := flag.Bool("force", false, "Force action")
flag.Usage = usage
flag.Parse()
args := flag.Args()
if len(args) > 0 {
action = args[0]
}
switch action {
case "encrypt":
rest_args := args[1:]
err = Encrypt(rest_args)
case "generate":
err = GenerateConfig(*force)
case "mount":
err = Mount()
case "umount":
err = UMount()
case "automount":
err = AutoMount()
default:
flag.Usage()
}
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}