initialize core in main()

This commit is contained in:
nytpu
2021-03-18 10:37:00 -06:00
parent a3a427b9ee
commit c145f8d4d2
+8 -4
View File
@@ -8,11 +8,12 @@ package main
import ( import (
"fmt" "fmt"
"log"
"os" "os"
"path/filepath" "path/filepath"
"github.com/mitchellh/go-homedir" "github.com/mitchellh/go-homedir"
"golang.nytpu.com/comitium/core"
) )
func main() { func main() {
@@ -45,6 +46,11 @@ func main() {
// dataPath is the location where all the data (list of subs, cached hashes, // dataPath is the location where all the data (list of subs, cached hashes,
// etcetera) are stored // etcetera) are stored
dataPath := getDataPath() dataPath := getDataPath()
err := core.Init(dataPath)
if err != nil {
fmt.Fprintf(os.Stderr, "Error in initialization: %v\n", err)
os.Exit(1)
}
switch os.Args[1] { switch os.Args[1] {
case "refresh": case "refresh":
@@ -57,8 +63,6 @@ func main() {
case "remove": case "remove":
fmt.Println("Remove") fmt.Println("Remove")
} }
fmt.Printf("Detected data path: %v\n", dataPath)
} }
// verifyPath will expand ~ if neccessary and will clean the path. // verifyPath will expand ~ if neccessary and will clean the path.
@@ -94,7 +98,7 @@ func getDataPath() string {
return verifyPath(home + "/.comitium") return verifyPath(home + "/.comitium")
} }
log.Printf("Error finding a suitable directory! Falling back to the current working directory. See \"comitium help\" or comitium(1) for more information.") fmt.Fprintln(os.Stderr, "Error finding a suitable directory! Falling back to the current working directory. See \"comitium help\" or comitium(1) for more information.")
return verifyPath("comitium") return verifyPath("comitium")
} }