1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

fix: define flags on init

chore: remove deprecated config files
This commit is contained in:
Ferdinand Mütsch 2020-10-04 11:47:03 +02:00
parent 29619f09ed
commit b378597594
3 changed files with 9 additions and 28 deletions

View File

@ -1,8 +0,0 @@
ENV=dev
WAKAPI_DB_TYPE=sqlite3 # mysql, postgres, sqlite3
WAKAPI_DB_NAME=wakapi_db.db # database name for mysql / postgres or file path for sqlite (e.g. /tmp/wakapi.db)
WAKAPI_DB_USER=myuser # ignored when using sqlite
WAKAPI_DB_PASSWORD=shhh # ignored when using sqlite
WAKAPI_DB_HOST=localhost # ignored when using sqlite
WAKAPI_DB_PORT=3306 # ignored when using sqlite
WAKAPI_PASSWORD_SALT=shhh # CHANGE !

View File

@ -1,15 +0,0 @@
[server]
listen = 127.0.0.1
port = 3000
base_path = /
insecure_cookies = false
[app]
cleanup = false
[database]
max_connections = 2
[languages]
vue = Vue
jsx = JSX

View File

@ -20,7 +20,10 @@ const (
defaultEnvConfigPathLegacy = ".env" defaultEnvConfigPathLegacy = ".env"
) )
var cfg *Config var (
cfg *Config
cFlag *string
)
type appConfig struct { type appConfig struct {
CleanUp bool `default:"false" env:"WAKAPI_CLEANUP"` CleanUp bool `default:"false" env:"WAKAPI_CLEANUP"`
@ -60,6 +63,11 @@ type Config struct {
Server serverConfig Server serverConfig
} }
func init() {
cFlag = flag.String("c", defaultConfigPath, "config file location")
flag.Parse()
}
func (c *Config) IsDev() bool { func (c *Config) IsDev() bool {
return IsDev(c.Env) return IsDev(c.Env)
} }
@ -157,10 +165,6 @@ func readLanguageColors() map[string]string {
} }
func mustReadConfigLocation() string { func mustReadConfigLocation() string {
var cFlag = flag.String("c", defaultConfigPath, "config file location")
flag.Parse()
if _, err := os.Stat(*cFlag); err != nil { if _, err := os.Stat(*cFlag); err != nil {
log.Fatalf("failed to find config file at '%s'\n", *cFlag) log.Fatalf("failed to find config file at '%s'\n", *cFlag)
} }