mirror of https://github.com/gabehf/Koito.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
651 B
43 lines
651 B
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/gabehf/koito/engine"
|
|
)
|
|
|
|
var Version = "dev"
|
|
|
|
func main() {
|
|
if err := engine.Run(
|
|
readEnvOrFile,
|
|
os.Stdout,
|
|
Version,
|
|
); err != nil {
|
|
fmt.Fprintf(os.Stderr, "%s\n", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func readEnvOrFile(envName string) string {
|
|
envContent := os.Getenv(envName)
|
|
|
|
if envContent == "" {
|
|
filename := os.Getenv(envName + "_FILE")
|
|
|
|
if filename != "" {
|
|
b, err := os.ReadFile(filename)
|
|
|
|
if err != nil {
|
|
panic(fmt.Errorf("Failed to load file for %s_FILE (%s): %s", envName, filename, err))
|
|
}
|
|
|
|
envContent = strings.TrimSpace(string(b))
|
|
}
|
|
}
|
|
|
|
return envContent
|
|
}
|