0d9cea8b95
Signed-off-by: Tim Hårek Andreassen <tim@harek.no>
38 lines
861 B
Go
38 lines
861 B
Go
package cmd
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var rootCmd = &cobra.Command{
|
|
Use: "yr",
|
|
Short: "yr is CLI tool for weather forecasts",
|
|
Version: "v0.0.6",
|
|
}
|
|
|
|
func Execute() {
|
|
err := rootCmd.Execute()
|
|
if err != nil {
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
var (
|
|
isJson bool
|
|
isDebug bool
|
|
isUTC bool
|
|
isWeb bool
|
|
lon float64
|
|
lat float64
|
|
)
|
|
|
|
func init() {
|
|
rootCmd.PersistentFlags().BoolVar(&isJson, "json", false, "Result in JSON")
|
|
rootCmd.PersistentFlags().BoolVar(&isDebug, "debug", false, "Display debug info")
|
|
rootCmd.PersistentFlags().BoolVar(&isUTC, "utc", false, "Result times in UTC")
|
|
rootCmd.PersistentFlags().BoolVar(&isWeb, "web", false, "Open result in browser")
|
|
rootCmd.PersistentFlags().Float64VarP(&lon, "lon", "x", 0, "Longitude coordinate")
|
|
rootCmd.PersistentFlags().Float64VarP(&lat, "lat", "y", 0, "Latitude coordinate")
|
|
}
|