This repository has been archived by the owner on Nov 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
main.go
72 lines (63 loc) · 1.85 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
66
67
68
69
70
71
72
// Copyright 2016 Andrew E. Bruno
//
// This file is part of Whisperfish.
//
// Whisperfish is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Whisperfish is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Whisperfish. If not, see <http://www.gnu.org/licenses/>.
package main
import (
"flag"
"fmt"
"os"
log "github.com/sirupsen/logrus"
"github.com/aebruno/whisperfish/ui"
)
var (
Version = "dev-build"
versionFlag bool
debugFlag bool
convertFlag bool
attachmentFlag bool
)
func init() {
flag.BoolVar(&versionFlag, "version", false, "show version")
flag.BoolVar(&versionFlag, "v", false, "show version (shorthand)")
flag.BoolVar(&debugFlag, "debug", false, "debug to file")
flag.BoolVar(&debugFlag, "d", false, "debug to file (shorthand)")
flag.BoolVar(&convertFlag, "convert", false, "convert datastore")
flag.BoolVar(&attachmentFlag, "fix-attachments", false, "Add extensions to attachments")
}
func main() {
flag.Parse()
if versionFlag {
fmt.Printf("Whisperfish v%s\n", Version)
os.Exit(0)
}
if convertFlag {
ui.ConvertDataStore()
os.Exit(0)
} else if attachmentFlag {
ui.AddAttachmentExtensions()
os.Exit(0)
}
if debugFlag {
logFile, err := os.OpenFile("/tmp/whisperfish-app.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0600)
if err != nil {
log.Fatalf("error opening file: %v", err)
os.Exit(-1)
}
defer logFile.Close()
log.SetOutput(logFile)
}
ui.Run(Version)
}