source: main/branches/origin/main.go@ 6bbceb9

Last change on this file since 6bbceb9 was 6bbceb9, checked in by www <www@…>, 8 weeks ago

Mirrored from yuuka.git

git-svn-id: https://svn.chaotic.ninja/svn/yuuka-yakumo.izuru@1 0f3ee07c-c614-0a4d-b2a1-86c95f6ad348

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[6bbceb9]1// $TheSupernovaDuo: yuuka,v 0.1.1 2023/5/29 18:19:14 yakumo_izuru Exp $
2package main
3
4import (
5 "log"
6
7 "github.com/integrii/flaggy"
8)
9var (
10 format string = "AT"
11 region string
12 lang string = "en"
13)
14func main() {
15 flaggy.SetDescription("Yuuka is yet another client for wttr.in")
16 flaggy.SetVersion(FullVersion())
17
18 forecastCmd := flaggy.NewSubcommand("forecast")
19 forecastCmd.String(&format, "f", "format", "View options")
20 forecastCmd.String(&region, "r", "region", "Where to look at")
21 forecastCmd.String(&lang, "l", "language", "Set preferred language")
22 forecastCmd.Description = "Check the current forecast of an specific location"
23
24 moonCmd := flaggy.NewSubcommand("moon")
25 moonCmd.String(&format, "f", "format", "View options")
26 moodCmd.String(&lang, "l", "language", "Set preferred language")
27 moonCmd.Description = "See what's going on at the Moon"
28
29 flaggy.AttachSubcommand(forecastCmd, 1)
30 flaggy.AttachSubcommand(moonCmd, 1)
31
32 flaggy.Parse()
33
34 if forecastCmd.Used {
35 ShowForecast(region, format, lang)
36 } else if moonCmd.Used {
37 ShowMoonPhases(format, lang)
38 } else {
39 flaggy.ShowHelpAndExit("A subcommand is required")
40 }
41}
42func sanityCheck(err error) {
43 if err != nil {
44 log.Fatal(err)
45 }
46}
Note: See TracBrowser for help on using the repository browser.