/
tx.go
58 lines (49 loc) · 1.56 KB
/
tx.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
package main
import (
"os"
"github.com/jessevdk/go-flags"
)
// GlobalParser is the argument parser which holds all options and arguments.
var GlobalParser *flags.Parser = flags.NewNamedParser("tx", flags.HelpFlag|flags.PassDoubleDash)
var (
// TaskfilePath holds the path to the current active taskfile. By default,
// it's "./tasks".
TaskfilePath string
// DonefilePath holds the path to the current finished taskfile. The path
// is derived from TaskfilePath like so: "./.{TaskfilePath}.done".
DonefilePath string
// SyncfilePath holds the path to the current Syncfile. The path is derived
// from TaskfilePath like so: "./.{TaskfilePath}.sync".
SyncfilePath string
)
var (
// MainList is the tasklist which holds all active tasks. Managed by
// ListManager.
MainList = &Tasklist{}
// DoneList is the tasklist which holds all finished tasks. Managed by
// ListManager.
DoneList = &Tasklist{}
// ListManager is responsible for loading and saving taskfiles, both local
// files and Sync service data.
ListManager = &TasklistManager{}
)
// InitPathVariables initializes all filepath variables. Re-initialization is
// considered irregular and the function will return.
func InitPathVariables(taskfilePath string) {
if SyncfilePath != "" {
return
}
TaskfilePath = taskfilePath
DonefilePath = GetMetafilePath(".done", TaskfilePath)
SyncfilePath = GetMetafilePath(".sync", TaskfilePath)
}
func main() {
_, err := GlobalParser.Parse()
if err != nil {
if flags.WroteHelp(err) {
os.Stderr.WriteString(err.Error())
} else {
Error(ErrFlagParsing, err)
}
}
}