-
Notifications
You must be signed in to change notification settings - Fork 2
/
checksummer.go
57 lines (48 loc) · 865 Bytes
/
checksummer.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
package main
import (
"flag"
"fmt"
"os"
)
// VERSION sets the version
const VERSION = "v3.0.0"
// File holds the attributes
type File struct {
ID int64
Name string
Size int64
Mtime int64
Checksum string
}
func main() {
flag.Parse()
database := flag.Arg(0)
if database == "" {
fmt.Println("Checksummer version", VERSION)
fmt.Println("")
fmt.Println("Usage: ./checksummer sqlite3.db [search arguments]")
fmt.Println("")
fmt.Println("Example: ./checksummer myfiles.db")
fmt.Println("")
os.Exit(1)
}
// initialize database
db, err := Open(database)
checkErr(err)
db.Init()
basepath, _ := db.GetOption("basepath")
if basepath == "" {
db.ChangeBasepath()
}
term := flag.Arg(1)
if term != "" {
db.Search(term)
os.Exit(0)
}
LaunchGUI(db)
}
func checkErr(err error) {
if err != nil {
panic(err)
}
}