cmd

package
v0.0.0-...-be41bbe Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ApplicationName = "stepwise"

ApplicationName name of the appmication

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "stepwise",
	Short: "Starts the stepwise application.",
	Long: `Starts the stepwise application.
			If the application configuration file is not specified explicitly then
			it is searched for in the following locations:
				1. /etc/stepwise/stepwise.toml
				2. $HOME/.stepwise/stepwise.toml
				3. ./stepwise.toml`,

	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {

		if cfgFile != "" {

			viper.SetConfigFile(cfgFile)
		} else {

			viper.SetConfigName(ApplicationName)
			viper.AddConfigPath(fmt.Sprintf("/etc/%s", ApplicationName))
			viper.AddConfigPath(fmt.Sprintf("$HOME/.%s", ApplicationName))
			viper.AddConfigPath(".")
		}

		viper.SetDefault("server.cert-cache-dir", "/var/www/.cache")
		viper.SetDefault("server.address", ":443")
		viper.SetDefault("users.default-results-per-page", "20")
		viper.SetDefault("logging.level", logging.InfoLogLevel)
		viper.SetDefault("logging.format", logging.TextLoggingFormat)
		viper.SetDefault("logging.log-requests", false)

		viper.AutomaticEnv()

		err := viper.ReadInConfig()
		if err != nil {
			return fmt.Errorf("Unable to load config file: %s", err)
		}
		return nil
	},
}

RootCmd represents the base command when called without any subcommands

Functions

func Execute

func Execute()

Execute the root command of the application

Types

type AutoTLSConfig

type AutoTLSConfig struct {
	CertCacheDir  string   `mapstructure:"cert-cache-dir"`
	HostWhiteList []string `mapstructure:"host-white-list"`
}

type ServerConfig

type ServerConfig struct {
	Address string         `mapstructure:"address"`
	AutoTLS *AutoTLSConfig `mapstructure:"auto-tls"`
	TLS     *TLSConfig     `mapstructure:"tls"`
}

type TLSConfig

type TLSConfig struct {
	Cert string `mapstructure:"cert"`
	Key  string `mapstructure:"key"`
}

Jump to

Keyboard shortcuts

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