cmd

package
v0.0.0-...-83d12ba Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2018 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "lora-mapper",
	Short: "Tool to create coverage maps for LoRa network",
	Long:  `lora-mapper is a tool to create coverage maps for existing LoRa networks`,
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		var logLevel = log.InfoLevel
		var logHandlers []log.Handler

		if verbose {
			logHandlers = append(logHandlers, cliHandler.Default)
		}

		if debug {
			logLevel = log.DebugLevel
		}

		absLogFileLocation, err := filepath.Abs("lora-mapper.log")
		if err != nil {
			panic(err)
		}
		logFile, err = os.OpenFile(absLogFileLocation, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
		if err != nil {
			panic(err)
		}
		if err == nil {
			logHandlers = append(logHandlers, textHandler.New(logFile))
		}

		log.SetHandler(multiHandler.New(logHandlers...))
		log.SetLevel(logLevel)
	},

	PersistentPostRun: func(cmd *cobra.Command, args []string) {
		if logFile != nil {
			logFile.Close()
		}
	},
}

RootCmd represents the base command when called without any subcommands

Functions

func Execute

func Execute()

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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