-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
73 lines (55 loc) · 1.82 KB
/
Copy pathmain.go
File metadata and controls
73 lines (55 loc) · 1.82 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
65
66
67
68
69
70
71
72
73
package main
import (
"fmt"
"log"
"github.com/alecthomas/kong"
)
const RemoveWorkingDatabase = false
const WorkerThreads = 4
const LargeFileThreshold = 1024 * 1024 * 16
var cli struct {
Recurse bool `help:"Recurse into subdirectories." short:"r" name:"recurse"`
HashType string `help:"Select hash algorithm. Valid options are blake2b-512 and sha512." short:"t" name:"hashtype" enum:"blake2b-512,sha512" default:"blake2b-512"`
Base64 bool `help:"Write sums in RFC 4648 base 64 rather than hexadecimal." short:"" name:"base64"`
Verbose bool `help:"Show progress." short:"v" name:"verbose"`
UseCWD bool `help:"Store resume database in the current working directory rather than in the user cache directory." short:"c" name:"usecwd"`
Output string `required:"" help:"Output filename" short:"o" name:"output"`
Paths []string `arg:"" help:"Input files" name:"paths"`
}
var DB SqliteStruct
var WorkingDatabaseInCWD bool
var UseBase64 bool
var Verbose bool
func main() {
var err error
fmt.Print("rsum release 0. THIS IS EXPERIMENTAL SOFTWARE. DO NOT USE IT FOR ANYTHING IMPORTANT.\n\n")
kong.Parse(&cli,
kong.Name("rsum"),
kong.Description("Recursive Sum Tool"),
kong.UsageOnError(),
kong.ConfigureHelp(kong.HelpOptions{
Compact: true,
Summary: true,
}))
DB, err = DBConnect()
if err != nil {
log.Panic(err)
}
defer DB.Close()
UseBase64 = cli.Base64
Verbose = cli.Verbose
WorkingDatabaseInCWD = cli.UseCWD
switch cli.HashType {
case "blake2b-512":
HashType = HashTypeBlake2B
case "sha512":
HashType = HashTypeSHA512
case "sha3-512":
HashType = HashTypeSHA3_512
}
// w, err := os.OpenFile("rsum.prof", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600)
// defer w.Close()
// runtime.StartCPUProfile(w)
CreateSumList(cli.Paths, cli.Recurse, cli.Output)
// runtime.StopCPUProfile()
}