mirror of https://github.com/synctv-org/synctv
Feat: load flags form env
parent
fc07d2d85c
commit
0b0b7e5ff1
@ -1,28 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/synctv-org/synctv/internal/bootstrap"
|
||||
)
|
||||
|
||||
var ConfCmd = &cobra.Command{
|
||||
Use: "conf",
|
||||
Short: "init or check",
|
||||
Long: `Init or check config file for correctness`,
|
||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
return bootstrap.New(bootstrap.WithContext(cmd.Context())).Add(
|
||||
bootstrap.InitConfig,
|
||||
).Run()
|
||||
},
|
||||
RunE: Conf,
|
||||
}
|
||||
|
||||
func Conf(cmd *cobra.Command, args []string) error {
|
||||
logrus.Infof("success")
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
RootCmd.AddCommand(ConfCmd)
|
||||
}
|
||||
@ -1,22 +1,9 @@
|
||||
package flags
|
||||
|
||||
// Global
|
||||
var (
|
||||
Dev bool
|
||||
|
||||
LogStd bool
|
||||
|
||||
SkipEnv bool
|
||||
|
||||
EnvFileOverload bool
|
||||
|
||||
SkipConfig bool
|
||||
|
||||
EnvNoPrefix bool
|
||||
|
||||
GitHubBaseURL string
|
||||
|
||||
DataDir string
|
||||
|
||||
ForceAutoMigrate bool
|
||||
)
|
||||
type GlobalFlags struct {
|
||||
Dev bool `env:"DEV"`
|
||||
LogStd bool `env:"LOG_STD"`
|
||||
GitHubBaseURL string `env:"GITHUB_BASE_URL"`
|
||||
DataDir string `env:"DATA_DIR"`
|
||||
ForceAutoMigrate bool `env:"FORCE_AUTO_MIGRATE"`
|
||||
}
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package flags
|
||||
|
||||
var (
|
||||
DisableUpdateCheck bool
|
||||
DisableWeb bool
|
||||
WebPath string
|
||||
DisableLogColor bool
|
||||
)
|
||||
type ServerFlags struct {
|
||||
SkipConfig bool `env:"SKIP_CONFIG"`
|
||||
SkipEnvConfig bool `env:"SKIP_ENV_CONFIG"`
|
||||
DisableUpdateCheck bool `env:"DISABLE_UPDATE_CHECK"`
|
||||
DisableWeb bool `env:"DISABLE_WEB"`
|
||||
WebPath string `env:"WEB_PATH"`
|
||||
DisableLogColor bool `env:"DISABLE_LOG_COLOR"`
|
||||
}
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
package flags
|
||||
|
||||
var (
|
||||
// Global
|
||||
EnvNoPrefix bool
|
||||
SkipEnvFlag bool
|
||||
Global GlobalFlags
|
||||
|
||||
// Server
|
||||
Server ServerFlags
|
||||
)
|
||||
|
||||
const (
|
||||
ENV_PREFIX = "SYNCTV_"
|
||||
)
|
||||
Loading…
Reference in New Issue