-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (38 loc) · 938 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
41
42
43
44
package main
import (
"fmt"
"os"
"github.com/declan94/secret-share/internal/exitcode"
"github.com/declan94/secret-share/internal/tlog"
"github.com/declan94/secret-share/secretshare"
)
// ReleaseVersion Release version string
const ReleaseVersion = "v0.1"
func main() {
args := ParseArgs()
if args.Version {
printVersion()
return
}
var err error
if args.Recover {
if args.Directory {
err = secretshare.RecoverDirectory(args.Src, args.Parts)
} else {
err = secretshare.RecoverFile(args.Src, args.Parts)
}
} else {
if args.Directory {
err = secretshare.ShareDirectory(args.Src, args.Parts, byte(args.KNum))
} else {
err = secretshare.ShareFile(args.Src, args.Parts, byte(args.KNum))
}
}
if err != nil {
tlog.Fatal.Println(err)
os.Exit(exitcode.Execution)
}
}
func printVersion() {
fmt.Printf("secret-share %s; share parts format version: %d.\n", ReleaseVersion, secretshare.CurVersion)
}