2017-06-30 21:10:25 +05:30
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
2020-01-05 23:09:17 +05:30
|
|
|
"os/signal"
|
2018-02-15 16:50:17 +05:30
|
|
|
"strings"
|
2020-01-05 23:09:17 +05:30
|
|
|
"syscall"
|
2017-06-30 21:10:25 +05:30
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/spf13/viper"
|
2020-01-03 03:21:57 +05:30
|
|
|
|
|
|
|
"github.com/elyby/chrly/version"
|
2017-06-30 21:10:25 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
var RootCmd = &cobra.Command{
|
2018-02-15 02:19:22 +05:30
|
|
|
Use: "chrly",
|
|
|
|
Short: "Implementation of Minecraft skins system server",
|
2020-01-03 03:21:57 +05:30
|
|
|
Version: version.Version(),
|
2017-06-30 21:10:25 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
// Execute adds all child commands to the root command and sets flags appropriately.
|
|
|
|
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
|
|
|
func Execute() {
|
|
|
|
if err := RootCmd.Execute(); err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-24 04:09:40 +05:30
|
|
|
func init() {
|
2017-06-30 21:10:25 +05:30
|
|
|
cobra.OnInitialize(initConfig)
|
|
|
|
}
|
|
|
|
|
|
|
|
func initConfig() {
|
2017-08-15 03:13:31 +05:30
|
|
|
viper.AutomaticEnv()
|
2018-02-15 16:50:17 +05:30
|
|
|
replacer := strings.NewReplacer(".", "_")
|
|
|
|
viper.SetEnvKeyReplacer(replacer)
|
2017-06-30 21:10:25 +05:30
|
|
|
}
|
2020-01-05 23:09:17 +05:30
|
|
|
|
|
|
|
func waitForExitSignal() os.Signal {
|
|
|
|
ch := make(chan os.Signal, 1)
|
|
|
|
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
|
|
|
|
|
|
|
|
return <-ch
|
|
|
|
}
|