cmd

package
v0.7.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2024 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const SelfUpdateLong = `` /* 207-byte string literal not displayed */

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "synctv",
	Short: "synctv",
	Long:  `synctv https://github.com/synctv-org/synctv`,
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		prefix := flags.ENV_PREFIX
		if !flags.SkipEnvFlag {
			s, ok := os.LookupEnv("ENV_NO_PREFIX")
			if ok {
				if strings.ToLower(s) == "true" {
					flags.EnvNoPrefix = true
				}
			}
			if flags.EnvNoPrefix {
				prefix = ""
				log.Info("load flags from env without prefix")
			} else {
				log.Infof("load flags from env with prefix: %s", prefix)
			}
		}
		if !flags.SkipEnvFlag {
			dataDir, ok := os.LookupEnv(prefix + "DATA_DIR")
			if ok {
				flags.Global.DataDir = dataDir
			}
			dev, ok := os.LookupEnv(prefix + "DEV")
			if ok {
				if strings.ToLower(dev) == "true" {
					flags.Global.Dev = true
				}
			}
		}

		envFiles, err := utils.GetEnvFiles(flags.Global.DataDir)
		if err != nil {
			logrus.Warnf("get env files error: %v", err)
		}
		if flags.Global.Dev {
			moreEnvFiles, err := utils.GetEnvFiles(".")
			if err != nil {
				logrus.Warnf("get env files error: %v", err)
			}
			envFiles = append(envFiles, moreEnvFiles...)
		}
		if len(envFiles) != 0 {
			log.Infof("load env from: %v", envFiles)
			err = godotenv.Load(envFiles...)
			if err != nil {
				logrus.Fatalf("load env error: %v", err)
			}
		}

		if !flags.SkipEnvFlag {
			err := env.ParseWithOptions(&flags.Global, env.Options{Prefix: prefix})
			if err != nil {
				logrus.Fatalf("parse env error: %v", err)
			}
			err = env.ParseWithOptions(&flags.Server, env.Options{Prefix: prefix})
			if err != nil {
				logrus.Fatalf("parse env error: %v", err)
			}
		}
	},
}
View Source
var SelfUpdateCmd = &cobra.Command{
	Use:   "self-update",
	Short: "self-update",
	Long:  SelfUpdateLong,
	PreRunE: func(cmd *cobra.Command, args []string) error {
		return bootstrap.New(bootstrap.WithContext(cmd.Context())).Add(
			bootstrap.InitStdLog,
		).Run()
	},
	RunE: SelfUpdate,
}
View Source
var ServerCmd = &cobra.Command{
	Use:   "server",
	Short: "Start synctv-server",
	Long:  `Start synctv-server`,
	PreRunE: func(cmd *cobra.Command, args []string) error {
		boot := bootstrap.New(bootstrap.WithContext(cmd.Context())).Add(
			bootstrap.InitSysNotify,
			bootstrap.InitConfig,
			bootstrap.InitGinMode,
			bootstrap.InitLog,
			bootstrap.InitDatabase,
			bootstrap.InitProvider,
			bootstrap.InitOp,
			bootstrap.InitRtmp,
			bootstrap.InitVendorBackend,
			bootstrap.InitSetting,
		)
		if !flags.Server.DisableUpdateCheck {
			boot.Add(bootstrap.InitCheckUpdate)
		}
		return boot.Run()
	},
	Run: Server,
}
View Source
var VersionCmd = &cobra.Command{
	Use:   "version",
	Short: "Print the version number of Sync TV Server",
	Long:  `All software has versions. This is Sync TV Server's`,
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Printf("synctv %s\n", version.Version)
		fmt.Printf("- web/version: %s\n", version.WebVersion)
		fmt.Printf("- git/commit: %s\n", version.GitCommit)
		fmt.Printf("- os/platform: %s\n", runtime.GOOS)
		fmt.Printf("- os/arch: %s\n", runtime.GOARCH)
		fmt.Printf("- go/version: %s\n", runtime.Version())
		fmt.Printf("- go/compiler: %s\n", runtime.Compiler)
	},
}

Functions

func Execute

func Execute()

func SelfUpdate added in v0.2.4

func SelfUpdate(cmd *cobra.Command, args []string) error

func Server

func Server(cmd *cobra.Command, args []string)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL