-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
65 lines (52 loc) · 1.36 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
61
62
63
64
65
package main
import (
"fmt"
"os"
"github.com/andrewmolyuk/pixar"
"github.com/andrewmolyuk/pixar/app"
"github.com/andrewmolyuk/pixar/exitor"
"github.com/andrewmolyuk/pixar/log"
"github.com/jessevdk/go-flags"
)
var (
version = "0.1.2.DEVELOPMENT"
commit = "UNKNOWN"
)
func main() {
pixarApp := app.Pixar{
BuildInfo: pixar.BuildInfo{
Version: version,
Commit: commit,
},
}
parser := flags.NewParser(&pixarApp, flags.Default)
parser.ShortDescription = "Pixar is command line pics archiver"
parser.LongDescription = "Scan folders and move photos and videos into folders according to their EXIF information"
if _, err := parser.Parse(); err != nil {
code := 1
if fe, ok := err.(*flags.Error); ok {
if fe.Type == flags.ErrHelp {
code = 0
}
}
os.Exit(code)
}
if pixarApp.ShowVersion {
fmt.Printf("Pixar %s\n", fmt.Sprintf("%s (git: %s)", version, commit[:7]))
os.Exit(0)
}
log.InitDefault(pixarApp.Debug, nil, true, exitor.Default())
if pixarApp.Extensions == "" {
pixarApp.Extensions = ".jpeg,.jpg,.tiff,.png,.heic"
}
if pixarApp.DuplicatesPolicy == "" {
pixarApp.DuplicatesPolicy = "skip"
}
if pixarApp.DuplicatesPolicy != "skip" && pixarApp.DuplicatesPolicy != "folder" {
log.Error("Duplicates policy must be either 'skip' or 'folder'")
}
if pixarApp.Simulation {
log.Warn("SIMULATION MODE")
}
pixarApp.Run()
}