cmd

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "ficsit",
	Short: "cli mod manager for satisfactory",
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
		viper.SetConfigName("config")
		viper.AddConfigPath(".")
		viper.SetEnvPrefix("ficsit")
		viper.AutomaticEnv()

		_ = viper.ReadInConfig()

		level, err := zerolog.ParseLevel(viper.GetString("log"))
		if err != nil {
			panic(err)
		}

		zerolog.SetGlobalLevel(level)

		writers := make([]io.Writer, 0)
		if viper.GetBool("pretty") {
			pterm.EnableStyling()
		} else {
			pterm.DisableStyling()
		}

		if !viper.GetBool("quiet") {
			writers = append(writers, zerolog.ConsoleWriter{
				Out:        os.Stdout,
				TimeFormat: time.RFC3339,
			})
		}

		if viper.GetString("log-file") != "" {
			logFile, err := os.OpenFile(viper.GetString("log-file"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0777)

			if err != nil {
				return errors.Wrap(err, "failed to open log file")
			}

			writers = append(writers, logFile)
		}

		log.Logger = zerolog.New(io.MultiWriter(writers...)).With().Timestamp().Logger()

		return nil
	},
}

Functions

func Execute

func Execute(version string, commit string)

Types

This section is empty.

Directories

Path Synopsis
mod

Jump to

Keyboard shortcuts

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