-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
59 lines (44 loc) · 912 Bytes
/
Copy pathmain.go
File metadata and controls
59 lines (44 loc) · 912 Bytes
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 (
"fmt"
// "log"
"os"
"path/filepath"
"github.com/fl4vis/sonar/app"
)
func main() {
// Get config directory
configDir, err := os.UserConfigDir()
if err != nil {
fmt.Println("Error getting user config dir:", err)
return
}
sonarDir := filepath.Join(configDir, "sonar")
filePath := filepath.Join(sonarDir, "directories.txt")
configDirFile := app.NewDirFile(sonarDir, filePath)
err = configDirFile.EnsureConfigExistence()
if err != nil {
return
}
// Arguments
args := os.Args[1:]
if len(args) > 0 && len(args) == 1 {
var dir string
switch args[0] {
case "+":
dir, _ = os.Getwd()
configDirFile.AppenToFile(dir)
break
case "-":
dir, _ = os.Getwd()
configDirFile.RemoveDirFromFile(dir)
break
}
os.Exit(0)
} else if len(args) > 1 {
fmt.Println("Only one argument required")
os.Exit(0)
}
// GUI
app.NewTea(*configDirFile)
}