Exemple #1
0
func init() {
	RootCmd.AddCommand(serveCmd)

	// @NOTE: Do not set the default values here, that doesn't work correctly!
	serveCmd.Flags().BoolP("daemon", "d", false, "Run as a daemon and detach from terminal")
	serveCmd.Flags().StringP("address", "a", "", "Set address:port to listen on")
	serveCmd.Flags().StringP("domain", "e", "", "Set domain to use with cookies")
	serveCmd.Flags().StringP("databasepath", "f", "", "Set path to database where the user infos are stored")
	serveCmd.Flags().IntP("cookiemaxage", "m", 4, "Set magical cookie's lifetime before it expires (in hours)")
	serveCmd.Flags().StringP("cookiesecret", "c", "", "Secret string to use in signing cookies")

	viper.BindPFlag("address", serveCmd.Flags().Lookup("address"))
	viper.BindPFlag("domain", serveCmd.Flags().Lookup("domain"))
	viper.BindPFlag("databasepath", serveCmd.Flags().Lookup("databasepath"))
	viper.BindPFlag("cookiemaxage", serveCmd.Flags().Lookup("cookiemaxage"))
	viper.BindPFlag("cookiesecret", serveCmd.Flags().Lookup("cookiesecret"))

	viper.SetDefault("address", "127.0.0.1:9434")
	viper.SetDefault("domain", ".secure.mydomain.eu")
	viper.SetDefault("databasepath", "./database.json")
	viper.SetDefault("cookiemaxage", 4)
	viper.SetDefault("cookiesecret", "CHOOSE-A-SECRET-YOURSELF")

	// Here you will define your flags and configuration settings.

	// Cobra supports Persistent Flags which will work for this command
	// and all subcommands, e.g.:
	// serveCmd.PersistentFlags().String("foo", "", "A help for foo")

	// Cobra supports local flags which will only run when this command
	// is called directly, e.g.:
	// serveCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")

}
Exemple #2
0
func init() {
	RootCmd.AddCommand(devicesCmd)
	devicesCmd.PersistentFlags().String("app-id", "", "The app ID to use")
	viper.BindPFlag("app-id", devicesCmd.PersistentFlags().Lookup("app-id"))
	devicesCmd.PersistentFlags().String("app-eui", "", "The app EUI to use")
	viper.BindPFlag("app-eui", devicesCmd.PersistentFlags().Lookup("app-eui"))
}
Exemple #3
0
func init() {
	cobra.OnInitialize(initConfig)

	// Here you will define your flags and configuration settings.
	// Cobra supports Persistent Flags, which, if defined here,
	// will be global for your application.

	RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.nessusControl.yaml)")
	// Cobra also supports local flags, which will only run
	// when this action is called directly.
	RootCmd.PersistentFlags().StringP("username", "u", "admin", "The username to log into Nessus.")
	RootCmd.PersistentFlags().StringP("password", "a", "Th1sSh0u1dB3AStr0ngP422w0rd", "The password to use to log into Nessus.")
	RootCmd.PersistentFlags().StringP("hostname", "o", "127.0.0.1", "The host where Nessus is located.")
	RootCmd.PersistentFlags().StringP("port", "p", "8834", "The port number used to connect to Nessus.")
	RootCmd.PersistentFlags().BoolP("debug", "d", false, "Use this flag to enable debug mode")

	viper.BindPFlag("auth.username", RootCmd.PersistentFlags().Lookup("username"))
	viper.SetDefault("auth.username", "admin")
	viper.BindPFlag("auth.password", RootCmd.PersistentFlags().Lookup("password"))
	viper.SetDefault("auth.password", "Th1sSh0u1dB3AStr0ngP422w0rd")
	viper.BindPFlag("nessusLocation.hostname", RootCmd.PersistentFlags().Lookup("hostname"))
	viper.SetDefault("nessusLocation.hostname", "127.0.0.1")
	viper.BindPFlag("nessusLocation.port", RootCmd.PersistentFlags().Lookup("port"))
	viper.SetDefault("nessusLocation.port", "8834")
	viper.BindPFlag("debug", RootCmd.PersistentFlags().Lookup("debug"))
	viper.SetDefault("debug", "8834")
}
func init() {
	cobra.OnInitialize(initConfig)
	RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cobra.yaml)")
	RootCmd.PersistentFlags().StringVarP(&projectBase, "projectbase", "b", "", "base project directory, e.g. github.com/spf13/")
	RootCmd.PersistentFlags().StringP("author", "a", "YOUR NAME", "Author name for copyright attribution")
	RootCmd.PersistentFlags().StringVarP(&userLicense, "license", "l", "", "Name of license for the project (can provide `licensetext` in config)")
	RootCmd.PersistentFlags().Bool("viper", true, "Use Viper for configuration")
	viper.BindPFlag("author", RootCmd.PersistentFlags().Lookup("author"))
	viper.BindPFlag("projectbase", RootCmd.PersistentFlags().Lookup("projectbase"))
	viper.BindPFlag("useViper", RootCmd.PersistentFlags().Lookup("viper"))
	viper.SetDefault("author", "NAME HERE <EMAIL ADDRESS>")
	viper.SetDefault("license", "apache")
	viper.SetDefault("licenseText", `
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
`)
}
Exemple #5
0
func init() {
	GrasshopperCmd.PersistentFlags().BoolVarP(&Verbose, "verbose", "v", false, "verbose output")
	GrasshopperCmd.PersistentFlags().BoolVarP(&Quiet, "quiet", "q", false, "quiet output")
	GrasshopperCmd.PersistentFlags().BoolVarP(&Log, "log", "l", true, "write logging output to file")
	GrasshopperCmd.PersistentFlags().BoolVarP(&Experimental, "experimental", "x", true, "write experimental output to stdout")

	grasshopperCmdV = GrasshopperCmd

	viper.BindPFlag("verbose", GrasshopperCmd.PersistentFlags().Lookup("verbose"))
	viper.BindPFlag("quiet", GrasshopperCmd.PersistentFlags().Lookup("quiet"))
	viper.BindPFlag("log", GrasshopperCmd.PersistentFlags().Lookup("log"))
	viper.BindPFlag("experimental", GrasshopperCmd.PersistentFlags().Lookup("experimental"))

	if Log {
		jww.SetLogFile("grasshopper.log")
	}

	if Quiet {
		jww.SetStdoutThreshold(jww.LevelWarn)
	}

	if Verbose {
		jww.SetLogThreshold(jww.LevelTrace)
		jww.SetStdoutThreshold(jww.LevelTrace)
	}

}
Exemple #6
0
func main() {
	mainCmd.AddCommand(versionCmd)
	mainCmd.AddCommand(generateCmd)
	mainCmd.AddCommand(transactCmd)
	mainCmd.AddCommand(logCmd)
	mainCmd.AddCommand(httpCmd)
	mainCmd.AddCommand(domainsCmd)

	viper.SetEnvPrefix("ORIGINS")
	viper.AutomaticEnv()

	// Default locations for the origins config file.
	viper.SetConfigName("origins")

	// Directory the program is being called from
	dir, err := filepath.Abs(filepath.Dir(os.Args[0]))

	if err == nil {
		viper.AddConfigPath(dir)
	}

	flags := mainCmd.PersistentFlags()

	flags.String("log", "info", "Level of log messages to emit. Choices are: debug, info, warn, error, fatal, panic.")
	flags.String("config", "", "Path to config file. Defaults to a origins.{json,yml,yaml} in the current working directory.")

	viper.BindPFlag("log", flags.Lookup("log"))
	viper.BindPFlag("config", flags.Lookup("config"))

	// If the target subcommand is generate, remove the generator
	// arguments to prevent flag parsing errors.
	args := parseGenerateArgs(os.Args[1:])

	// Set explicit arguments and parse the flags to setup
	// the config file and logging.
	mainCmd.SetArgs(args)
	mainCmd.ParseFlags(args)

	config := viper.GetString("config")

	if config != "" {
		viper.SetConfigFile(config)
	}

	// Read configuration file if present.
	viper.ReadInConfig()

	// Turn on debugging for all commands.
	level, err := logrus.ParseLevel(viper.GetString("log"))

	if err != nil {
		fmt.Println("Invalid log level choice.")
		mainCmd.Help()
	}

	logrus.SetLevel(level)

	mainCmd.Execute()
}
Exemple #7
0
func init() {
	serverCmd.Flags().Int("serverPort", 7767, "Port to run the REST server on")
	serverCmd.Flags().String("serverUsername", "", "HTTP Basic auth username that the REST server will require")
	serverCmd.Flags().String("serverPassword", "", "HTTP Basic auth password that the REST server will require")
	viper.BindPFlag("server.port", serverCmd.Flags().Lookup("serverPort"))
	viper.BindPFlag("server.username", serverCmd.Flags().Lookup("serverUsername"))
	viper.BindPFlag("server.password", serverCmd.Flags().Lookup("serverPassword"))
}
Exemple #8
0
func init() {
	flags := httpCmd.Flags()

	flags.String("host", "127.0.0.1", "Host of the HTTP server.")
	flags.Int("port", 7000, "Port of the HTTP server.")

	viper.BindPFlag("http.host", flags.Lookup("host"))
	viper.BindPFlag("http.port", flags.Lookup("port"))
}
Exemple #9
0
Fichier : root.go Projet : Luit/rcp
func init() {
	cobra.OnInitialize(initConfig)
	rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file (default is $HOME/.rcp.yaml)")

	rootCmd.PersistentFlags().IPP("bind", "b", net.IPv4(127, 0, 0, 1), "IP address to bind to")
	viper.BindPFlag("bind", rootCmd.PersistentFlags().Lookup("bind"))

	rootCmd.PersistentFlags().IntP("port", "p", 6379, "Port to listen on")
	viper.BindPFlag("port", rootCmd.PersistentFlags().Lookup("port"))
}
Exemple #10
0
// init prepares cobra flags
func init() {
	cobra.OnInitialize(initConfig)

	Promu.PersistentFlags().StringVar(&cfgFile, "config", "", "Config file (default is ./.promu.yml)")
	Promu.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Verbose output")
	Promu.PersistentFlags().BoolVar(&useViper, "viper", true, "Use Viper for configuration")

	viper.BindPFlag("useViper", Promu.PersistentFlags().Lookup("viper"))
	viper.BindPFlag("verbose", Promu.PersistentFlags().Lookup("verbose"))
}
func init() {
	cobra.OnInitialize(initConfig)

	RootCmd.PersistentFlags().StringVar(&CfgFile, "config", "", "config file (default is $CWD/config.yaml)")
	RootCmd.PersistentFlags().StringP("address", "a", ":9000", "address to listen to")
	RootCmd.PersistentFlags().StringP("docker-endpoint", "d", "unix:///var/run/docker.sock", "docker host endpoint")

	// Bind viper to these flags so viper can read flag values along with config, env, etc.
	viper.BindPFlag("address", RootCmd.PersistentFlags().Lookup("address"))
	viper.BindPFlag("docker-endpoint", RootCmd.PersistentFlags().Lookup("docker-endpoint"))
}
Exemple #12
0
func init() {
	dlCmd.Flags().StringP("languages", "l", "en", "Languages of the subtitle separate by a comma (First to match is downloaded). Available languages at 'subify list languages'")
	dlCmd.Flags().StringP("apis", "a", "SubDB,OpenSubtitles", "Overwrite default searching APIs behavior, hence the subtitles are downloaded. Available APIs at 'subify list apis'")
	dlCmd.Flags().BoolVarP(&openVideo, "open", "o", false,
		"Once the subtitle is downloaded, open the video with your default video player"+
			` (OSX: "open", Windows: "start", Linux/Other: "xdg-open")`)
	viper.BindPFlag("download.languages", dlCmd.Flags().Lookup("languages"))
	viper.BindPFlag("download.apis", dlCmd.Flags().Lookup("apis"))

	RootCmd.AddCommand(dlCmd)
}
Exemple #13
0
func init() {
	flags := mainCmd.PersistentFlags()

	flags.Bool("prof", false, "Enable profiling.")
	flags.String("prof-path", "./prof", "The path to store output profiles.")
	flags.Float32("smallest-threshold", 0.6, "The ratio of the set size for the complement to be returned.")

	viper.BindPFlag("main.prof", flags.Lookup("prof"))
	viper.BindPFlag("main.prof-path", flags.Lookup("prof-path"))
	viper.BindPFlag("main.smallest-threshold", flags.Lookup("smallest-threshold"))
}
Exemple #14
0
func init() {
	flags := httpCmd.Flags()

	addStorageFlags(flags)

	flags.String("host", "", "The host the HTTP service will listen on.")
	flags.Int("port", 49110, "The port the HTTP will bind to.")

	viper.BindPFlag("http_host", flags.Lookup("host"))
	viper.BindPFlag("http_port", flags.Lookup("port"))
}
Exemple #15
0
func init() {
	RootCmd.AddCommand(routerCmd)
	routerCmd.Flags().String("server-address", "0.0.0.0", "The IP address to listen for communication")
	routerCmd.Flags().String("server-address-announce", "localhost", "The public IP address to announce")
	routerCmd.Flags().Int("server-port", 1901, "The port for communication")
	routerCmd.Flags().Bool("skip-verify-gateway-token", false, "Skip verification of the gateway token")
	viper.BindPFlag("router.server-address", routerCmd.Flags().Lookup("server-address"))
	viper.BindPFlag("router.server-address-announce", routerCmd.Flags().Lookup("server-address-announce"))
	viper.BindPFlag("router.server-port", routerCmd.Flags().Lookup("server-port"))
	viper.BindPFlag("router.skip-verify-gateway-token", routerCmd.Flags().Lookup("skip-verify-gateway-token"))
}
Exemple #16
0
func init() {
	flags := generateCmd.Flags()

	flags.String("domain", "", "Default domain to set on the facts.")
	flags.String("time", "", "The time the facts are true.")
	flags.String("operation", "", "The operation to apply to the facts, assert or retract.")

	viper.BindPFlag("generate_domain", flags.Lookup("domain"))
	viper.BindPFlag("generate_time", flags.Lookup("time"))
	viper.BindPFlag("generate_operation", flags.Lookup("operation"))
}
Exemple #17
0
func init() {
	cobra.OnInitialize(initConfig)
	// Default configuration can be overridden
	RootCmd.PersistentFlags().StringVar(&config.ConfigFile, "config", "",
		"Config file (default is $HOME/.subify.yaml|json|toml). Edit to change default behavior")
	RootCmd.PersistentFlags().BoolVarP(&config.Verbose, "verbose", "v", false,
		"Print more information while executing")
	RootCmd.PersistentFlags().BoolVarP(&config.Dev, "dev", "", false,
		"Instanciate development sandbox instead of production variables")
	viper.BindPFlag("root.dev", RootCmd.PersistentFlags().Lookup("dev"))
	viper.BindPFlag("root.verbose", RootCmd.PersistentFlags().Lookup("verbose"))
}
Exemple #18
0
func init() {
	RootCmd.AddCommand(createUserCmd)

	// @NOTE: Do not set the default values here, that doesn't work correctly!
	createUserCmd.Flags().StringP("name", "n", "", "username")
	createUserCmd.Flags().StringP("hmackey", "p", "", "hmackey")

	viper.BindPFlag("name", createUserCmd.Flags().Lookup("name"))
	viper.BindPFlag("hmackey", createUserCmd.Flags().Lookup("hmackey"))

	viper.SetDefault("hmackey", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
}
Exemple #19
0
func init() {
	cobra.OnInitialize(initConfig)
	RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cobra.yaml)")
	RootCmd.PersistentFlags().StringVarP(&projectBase, "projectbase", "b", "", "base project directory, e.g. github.com/spf13/")
	RootCmd.PersistentFlags().StringP("author", "a", "YOUR NAME", "Author name for copyright attribution")
	RootCmd.PersistentFlags().StringVarP(&userLicense, "license", "l", "", "Name of license for the project (can provide `license` in config)")
	RootCmd.PersistentFlags().Bool("viper", true, "Use Viper for configuration")
	viper.BindPFlag("author", RootCmd.PersistentFlags().Lookup("author"))
	viper.BindPFlag("projectbase", RootCmd.PersistentFlags().Lookup("projectbase"))
	viper.BindPFlag("useViper", RootCmd.PersistentFlags().Lookup("viper"))
	viper.SetDefault("author", "NAME HERE <EMAIL ADDRESS>")
	viper.SetDefault("license", "apache")
}
Exemple #20
0
func init() {
	flags := httpCmd.Flags()

	addStorageFlags(flags)

	flags.String("host", "", "The host the HTTP service will listen on.")
	flags.Int("port", 49110, "The port the HTTP will bind to.")
	flags.String("allowed-hosts", "*", "Set of allowed hosts for cross-origin resource sharing.")

	viper.BindPFlag("http_host", flags.Lookup("host"))
	viper.BindPFlag("http_port", flags.Lookup("port"))
	viper.BindPFlag("http_allowed_hosts", flags.Lookup("allowed-hosts"))
}
Exemple #21
0
func init() {
	cobra.OnInitialize(initConfig)

	// Setting flags here so they can be used by both the root behavior as well as
	// by the indidual behaviors of icarus and daedalus
	RootCmd.PersistentFlags().StringVar(&CfgFile, "config", "", "config file (default is $CWD/config.yaml)")
	RootCmd.PersistentFlags().IntP("port", "p", 8013, "Port run on")
	RootCmd.PersistentFlags().IntP("width", "x", 15, "width of the laybrinth")
	RootCmd.PersistentFlags().IntP("height", "y", 10, "height of the laybrinth") // 'h' is used for help already
	RootCmd.PersistentFlags().IntP("times", "t", 1, "times to solve the laybrinth")
	RootCmd.PersistentFlags().IntP("max-steps", "m", 500, "Maximum steps before giving up")
	RootCmd.PersistentFlags().BoolP("interactive", "i", false, "runs in interactive mode")
	RootCmd.PersistentFlags().BoolP("debug", "d", false, "prints debug messages")
	RootCmd.PersistentFlags().Float64P("braid", "b", 1.0, "probability to rearrange an dead end to a braid")

	// Bind viper to these flags so viper can read flag values along with config, env, etc.
	_ = viper.BindPFlag("width", RootCmd.PersistentFlags().Lookup("width"))
	_ = viper.BindPFlag("height", RootCmd.PersistentFlags().Lookup("height"))
	_ = viper.BindPFlag("port", RootCmd.PersistentFlags().Lookup("port"))
	_ = viper.BindPFlag("times", RootCmd.PersistentFlags().Lookup("times"))
	_ = viper.BindPFlag("max-steps", RootCmd.PersistentFlags().Lookup("max-steps"))
	_ = viper.BindPFlag("interactive", RootCmd.PersistentFlags().Lookup("interactive"))
	_ = viper.BindPFlag("debug", RootCmd.PersistentFlags().Lookup("debug"))
	_ = viper.BindPFlag("braid", RootCmd.PersistentFlags().Lookup("braid"))
}
Exemple #22
0
func init() {
	rand.Seed(time.Now().UTC().UnixNano()) // need to initialize the seed
	gin.SetMode(gin.ReleaseMode)

	daedalusCmd.Flags().IntP("width", "w", 15, "width of the laybrinth")
	daedalusCmd.Flags().IntP("height", "t", 10, "height of the laybrinth")

	// Bind viper to these flags so viper can also read them from config, env, etc.
	viper.SetDefault("width", 15)
	viper.SetDefault("height", 10)
	viper.BindPFlag("width", daedalusCmd.Flags().Lookup("width"))
	viper.BindPFlag("height", daedalusCmd.Flags().Lookup("height"))
	RootCmd.AddCommand(daedalusCmd)
}
Exemple #23
0
// TODO: Need to look at whether this is just too much going on.
func init() {
	// enable ability to specify config file via flag
	RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.trackello.yaml)")
	if cfgFile != "" {
		viper.SetConfigFile(cfgFile)
	}
	viper.SetConfigName(".trackello") // name of config file (without extension)

	// Set Environment Variables
	viper.SetEnvPrefix("trackello")
	viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_")) // replace environment variables to underscore (_) from hyphen (-)
	if err := viper.BindEnv("appkey", trackello.TRACKELLO_APPKEY); err != nil {
		panic(err)
	}
	if err := viper.BindEnv("token", trackello.TRACKELLO_TOKEN); err != nil {
		panic(err)
	}
	if err := viper.BindEnv("board", trackello.TRACKELLO_PREFERRED_BOARD); err != nil {
		panic(err)
	}
	viper.AutomaticEnv() // read in environment variables that match every time Get() is called

	// Add Configuration Paths
	if cwd, err := os.Getwd(); err == nil {
		viper.AddConfigPath(cwd)
	}
	viper.AddConfigPath("$HOME") // adding home directory as first search path

	// If a config file is found, read it in.
	if err := viper.ReadInConfig(); err == nil {
		fmt.Println("Using config file:", viper.ConfigFileUsed())
	}

	RootCmd.AddCommand(configCmd)

	RootCmd.PersistentFlags().StringVar(&trelloAppKey, "appkey", "", "Trello Application Key")
	if err := viper.BindPFlag("appkey", RootCmd.PersistentFlags().Lookup("appkey")); err != nil {
		panic(err)
	}
	RootCmd.PersistentFlags().StringVar(&trelloToken, "token", "", "Trello Token")
	if err := viper.BindPFlag("token", RootCmd.PersistentFlags().Lookup("token")); err != nil {
		panic(err)
	}
	RootCmd.PersistentFlags().StringVar(&preferredBoard, "board", "", "Preferred Board ID")
	if err := viper.BindPFlag("board", RootCmd.PersistentFlags().Lookup("board")); err != nil {
		panic(err)
	}
	viper.RegisterAlias("preferredBoard", "board")
}
Exemple #24
0
func init() {
	flags := transactCmd.Flags()

	addStorageFlags(flags)

	flags.String("format", "", "Format of the stream of facts. Choices are: csv")
	flags.String("compression", "", "Compression method of the stream of facts. Choices are: bzip2, gzip")
	flags.String("domain", "", "Default domain to transact the facts to. If not supplied, the fact domain attribute must be defined.")
	flags.Bool("fake", false, "If set, the transaction will not be committed.")

	viper.BindPFlag("transact_format", flags.Lookup("format"))
	viper.BindPFlag("transact_compression", flags.Lookup("compression"))
	viper.BindPFlag("transact_domain", flags.Lookup("domain"))
	viper.BindPFlag("transact_fake", flags.Lookup("fake"))
}
Exemple #25
0
// Checks for a config file, sets up sensible default options
func getConfigFile() {
	viper.SetConfigName("minecontrol")
	viper.AddConfigPath(".")
	configErr := viper.ReadInConfig()

	if configErr != nil {
		jww.WARN.Println("No config file found, using default values.")
	}

	// Bind config file values to the command line options passed in
	viper.BindPFlag("verbose", mcCmd.PersistentFlags().Lookup("verbose"))
	viper.BindPFlag("rcon.address", mcCmd.PersistentFlags().Lookup("address"))
	viper.BindPFlag("rcon.port", mcCmd.PersistentFlags().Lookup("port"))
	viper.BindPFlag("rcon.password", mcCmd.PersistentFlags().Lookup("password"))
}
Exemple #26
0
func buildServerCommand() *cobra.Command {
	var serverCommand = &cobra.Command{
		Use:   "server",
		Short: "Start your application",
		Long:  `Start your application, takes options:`,
		Run: func(cmd *cobra.Command, args []string) {
			app.Main()
		},
	}
	serverCommand.Flags().StringVarP(&DebugLevel, "debug", "d", "debug", "The log level for the application")
	viper.BindPFlag("debug", serverCommand.Flags().Lookup("debug"))
	serverCommand.Flags().IntVarP(&Port, "port", "p", 8888, "The port to listen on")
	viper.BindPFlag("port", serverCommand.Flags().Lookup("port"))
	return serverCommand
}
Exemple #27
0
// init initializes the configuration and command line flags
func init() {
	cobra.OnInitialize(initConfig)

	RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default \"$HOME/.ttntool.yaml\")")

	RootCmd.PersistentFlags().String("nwkSKey", "2B7E151628AED2A6ABF7158809CF4F3C", "Network Session key")
	RootCmd.PersistentFlags().String("appSKey", "2B7E151628AED2A6ABF7158809CF4F3C", "App Session key")

	RootCmd.PersistentFlags().String("broker", "croft.thethings.girovito.nl", "Broker address")

	viper.BindPFlag("nwkSKey", RootCmd.PersistentFlags().Lookup("nwkSKey"))
	viper.BindPFlag("appSKey", RootCmd.PersistentFlags().Lookup("appSKey"))

	viper.BindPFlag("broker", RootCmd.PersistentFlags().Lookup("broker"))
}
Exemple #28
0
func main() {
	var RootCmd = &cobra.Command{Use: "gg"}

	RootCmd.PersistentFlags().BoolVarP(&command.Verbose, "verbose", "v", false, "verbose output")
	RootCmd.PersistentFlags().StringVarP(&command.ConfigFile, "config", "c", "gg.yml", "configuration file")

	viper.BindPFlag("verbose", RootCmd.PersistentFlags().Lookup("verbose"))
	viper.BindPFlag("config", RootCmd.PersistentFlags().Lookup("config"))
	viper.SetDefault("config", "NAME HERE <EMAIL ADDRESS>")

	RootCmd.AddCommand(command.FrequencyCode)
	RootCmd.AddCommand(command.GogCmd)
	RootCmd.AddCommand(command.GogIdCmd)
	RootCmd.AddCommand(command.Worker)
	RootCmd.Execute()
}
Exemple #29
0
func init() {
	flags := domainCmd.Flags()

	flags.Bool("members", false, "Ouputs the members to stdout.")

	viper.BindPFlag("domain.members", flags.Lookup("members"))
}
Exemple #30
0
// init prepares cobra flags
func init() {
	Promu.AddCommand(buildCmd)

	buildCmd.Flags().String("prefix", "", "Specific dir to store binaries (default is .)")

	viper.BindPFlag("build.prefix", buildCmd.Flags().Lookup("prefix"))
}