49 lines
1.1 KiB
Go
Executable File
49 lines
1.1 KiB
Go
Executable File
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"local/args"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
var (
|
|
Port string
|
|
StoreType string
|
|
StoreAddr string
|
|
StoreUser string
|
|
StorePass string
|
|
Root string
|
|
MyTinyTodo string
|
|
)
|
|
|
|
func init() {
|
|
Refresh()
|
|
}
|
|
|
|
func Refresh() {
|
|
if strings.Contains(fmt.Sprint(os.Args), "-test") {
|
|
return
|
|
}
|
|
|
|
as := args.NewArgSet()
|
|
as.Append(args.STRING, "port", "port to listen on", "39909")
|
|
as.Append(args.STRING, "store", "type of store", "map")
|
|
as.Append(args.STRING, "storeaddr", "addr of store", "")
|
|
as.Append(args.STRING, "storeuser", "user of store", "")
|
|
as.Append(args.STRING, "storepass", "pass of store", "")
|
|
as.Append(args.STRING, "mtt", "url of php server", "http://localhost:38808")
|
|
as.Append(args.STRING, "root", "root of static files", "./public")
|
|
if err := as.Parse(); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
Port = ":" + strings.TrimPrefix(as.Get("port").GetString(), ":")
|
|
StoreType = as.Get("store").GetString()
|
|
StoreAddr = as.Get("storeaddr").GetString()
|
|
StoreUser = as.Get("storeuser").GetString()
|
|
StorePass = as.Get("storepass").GetString()
|
|
Root = as.Get("root").GetString()
|
|
MyTinyTodo = as.Get("mtt").GetString()
|
|
}
|