48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package badger
|
|
|
|
import (
|
|
"embed"
|
|
"strings"
|
|
"velvettear/badger/internal/api"
|
|
"velvettear/badger/internal/config"
|
|
"velvettear/badger/internal/database"
|
|
"velvettear/badger/internal/executables"
|
|
"velvettear/badger/internal/log"
|
|
"velvettear/badger/internal/tools"
|
|
)
|
|
|
|
var embeddedFiles *embed.FS
|
|
|
|
// exported function(s)
|
|
func Run() {
|
|
config.Initialize()
|
|
if config.Help() {
|
|
tools.PrintHelp()
|
|
}
|
|
setup()
|
|
api.StartServer()
|
|
// library.Update()
|
|
// library.Import()
|
|
// library.FindDuplicates()
|
|
}
|
|
|
|
func SetEmbeddedFiles(files *embed.FS) {
|
|
embeddedFiles = files
|
|
}
|
|
|
|
// unexported function(s)
|
|
func setup() {
|
|
home := config.HomeDirectory()
|
|
error := tools.MkDirs(home)
|
|
if error != nil {
|
|
log.Fatal("could not create home directory '"+home+"'", error.Error())
|
|
} else {
|
|
log.Info("created home directory '" + home + "'")
|
|
}
|
|
executables.Initialize()
|
|
executables.ExportExecutables(embeddedFiles)
|
|
if !executables.AreMandatoryExecutablesAvailable() {
|
|
log.Fatal("error locating all mandatory executables, make sure they are correctly installed on your system", strings.Join(executables.GetMissingExecutables(), ", "))
|
|
}
|
|
database.Initialize()
|
|
}
|