yr/cmd/root.go
Tim Hårek Andreassen 36309212a7
feat: Introduce cmd flags package
Signed-off-by: Tim Hårek Andreassen <tim@harek.no>
2024-10-02 15:47:49 +02:00

27 lines
573 B
Go

package cmd
import (
"os"
"git.sr.ht/~timharek/yr-go/cmd/flags"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "yr",
Short: "Get the weather for your desired location.",
Long: `Get the weather for your desired location.`,
}
func Execute() {
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}
func init() {
rootCmd.PersistentFlags().Bool(flags.JSON, false, "Result in JSON")
rootCmd.PersistentFlags().Float64P(flags.LON, "x", 0, "Longitude coordinate")
rootCmd.PersistentFlags().Float64P(flags.LAT, "y", 0, "Latitude coordinate")
}