]> Git repositories of Izuru Yakumo - yuuka.git/commitdiff
Mirrored from yuuka.git master
authorwww <www@0f3ee07c-c614-0a4d-b2a1-86c95f6ad348>
Sun, 29 Sep 2024 21:30:08 +0000 (21:30 +0000)
committerwww <www@0f3ee07c-c614-0a4d-b2a1-86c95f6ad348>
Sun, 29 Sep 2024 21:30:08 +0000 (21:30 +0000)
git-svn-id: https://svn.chaotic.ninja/svn/yuuka-yakumo.izuru@1 0f3ee07c-c614-0a4d-b2a1-86c95f6ad348

44 files changed:
branches/master/.gitignore [new file with mode: 0644]
branches/master/COPYING [new file with mode: 0644]
branches/master/Makefile [new file with mode: 0644]
branches/master/README.md [new file with mode: 0644]
branches/master/doc.go [new file with mode: 0644]
branches/master/go.mod [new file with mode: 0644]
branches/master/go.sum [new file with mode: 0644]
branches/master/main.go [new file with mode: 0644]
branches/master/showforecast.go [new file with mode: 0644]
branches/master/showmoonphases.go [new file with mode: 0644]
branches/master/version.go [new file with mode: 0644]
branches/origin-master/.gitignore [new file with mode: 0644]
branches/origin-master/COPYING [new file with mode: 0644]
branches/origin-master/Makefile [new file with mode: 0644]
branches/origin-master/README.md [new file with mode: 0644]
branches/origin-master/doc.go [new file with mode: 0644]
branches/origin-master/go.mod [new file with mode: 0644]
branches/origin-master/go.sum [new file with mode: 0644]
branches/origin-master/main.go [new file with mode: 0644]
branches/origin-master/showforecast.go [new file with mode: 0644]
branches/origin-master/showmoonphases.go [new file with mode: 0644]
branches/origin-master/version.go [new file with mode: 0644]
branches/origin/.gitignore [new file with mode: 0644]
branches/origin/COPYING [new file with mode: 0644]
branches/origin/Makefile [new file with mode: 0644]
branches/origin/README.md [new file with mode: 0644]
branches/origin/doc.go [new file with mode: 0644]
branches/origin/go.mod [new file with mode: 0644]
branches/origin/go.sum [new file with mode: 0644]
branches/origin/main.go [new file with mode: 0644]
branches/origin/showforecast.go [new file with mode: 0644]
branches/origin/showmoonphases.go [new file with mode: 0644]
branches/origin/version.go [new file with mode: 0644]
trunk/.gitignore [new file with mode: 0644]
trunk/COPYING [new file with mode: 0644]
trunk/Makefile [new file with mode: 0644]
trunk/README.md [new file with mode: 0644]
trunk/doc.go [new file with mode: 0644]
trunk/go.mod [new file with mode: 0644]
trunk/go.sum [new file with mode: 0644]
trunk/main.go [new file with mode: 0644]
trunk/showforecast.go [new file with mode: 0644]
trunk/showmoonphases.go [new file with mode: 0644]
trunk/version.go [new file with mode: 0644]

diff --git a/branches/master/.gitignore b/branches/master/.gitignore
new file mode 100644 (file)
index 0000000..1848005
--- /dev/null
@@ -0,0 +1 @@
+yuuka
diff --git a/branches/master/COPYING b/branches/master/COPYING
new file mode 100644 (file)
index 0000000..2cf0779
--- /dev/null
@@ -0,0 +1,13 @@
+Copyright (c) 2023-present Izuru Yakumo <yakumo.izuru@chaotic.ninja>
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/branches/master/Makefile b/branches/master/Makefile
new file mode 100644 (file)
index 0000000..c142e99
--- /dev/null
@@ -0,0 +1,19 @@
+PREFIX ?= /usr/local
+GOFLAGS ?= -v -ldflags "-w -X `go list`.Version=${VERSION} -X `go list`.Commit=${COMMIT} -X `go list`.Build=${BUILD}" -buildmode=exe
+
+VERSION ?= `git describe --abbrev=0 --tags || echo $VERSION`
+COMMIT ?= `git rev-parse --short HEAD || echo $COMMIT`
+BUILD ?= `git show -s --pretty=format:%cI`
+
+all: yuuka
+
+yuuka:
+       go build ${GOFLAGS}
+       @strip -s yuuka
+clean:
+       rm -f yuuka
+install:
+       install -Dm0755 yuuka ${DESTDIR}${PREFIX}/bin/yuuka
+uninstall:
+       rm -f ${DESTDIR}${PREFIX}/bin/yuuka
+
diff --git a/branches/master/README.md b/branches/master/README.md
new file mode 100644 (file)
index 0000000..081dd37
--- /dev/null
@@ -0,0 +1,2 @@
+# yuuka
+It's a [wttr](https://wttr.in) client, named after [Yuuka Kazami](https://en.touhouwiki.net/wiki/Yuuka_Kazami) from [Touhou 4: Lotus Land Story](https://en.touhouwiki.net/wiki/Lotus_Land_Story)
diff --git a/branches/master/doc.go b/branches/master/doc.go
new file mode 100644 (file)
index 0000000..13ae500
--- /dev/null
@@ -0,0 +1,3 @@
+// Package yuuka is yet another client for wttr.in
+// Homepage: https://suzunaan.chaotic.ninja/yuuka/
+package main
diff --git a/branches/master/go.mod b/branches/master/go.mod
new file mode 100644 (file)
index 0000000..106dbbd
--- /dev/null
@@ -0,0 +1,5 @@
+module marisa.chaotic.ninja/yuuka
+
+go 1.20
+
+require github.com/integrii/flaggy v1.5.2
diff --git a/branches/master/go.sum b/branches/master/go.sum
new file mode 100644 (file)
index 0000000..ec4c7d6
--- /dev/null
@@ -0,0 +1,5 @@
+github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
+github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/integrii/flaggy v1.5.2 h1:bWV20MQEngo4hWhno3i5Z9ISPxLPKj9NOGNwTWb/8IQ=
+github.com/integrii/flaggy v1.5.2/go.mod h1:dO13u7SYuhk910nayCJ+s1DeAAGC1THCMj1uSFmwtQ8=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
diff --git a/branches/master/main.go b/branches/master/main.go
new file mode 100644 (file)
index 0000000..e1c9388
--- /dev/null
@@ -0,0 +1,46 @@
+// $TheSupernovaDuo: yuuka,v 0.1.1 2023/5/29 18:19:14 yakumo_izuru Exp $
+package main
+
+import (
+       "log"
+
+       "github.com/integrii/flaggy"
+)
+var (
+       format string = "AT"
+       region string
+       lang string = "en"
+)
+func main() {
+       flaggy.SetDescription("Yuuka is yet another client for wttr.in")
+       flaggy.SetVersion(FullVersion())
+
+       forecastCmd := flaggy.NewSubcommand("forecast")
+       forecastCmd.String(&format, "f", "format", "View options")
+       forecastCmd.String(&region, "r", "region", "Where to look at")
+       forecastCmd.String(&lang, "l", "language", "Set preferred language")
+       forecastCmd.Description = "Check the current forecast of an specific location"
+
+       moonCmd := flaggy.NewSubcommand("moon")
+       moonCmd.String(&format, "f", "format", "View options")
+       moodCmd.String(&lang, "l", "language", "Set preferred language")
+       moonCmd.Description = "See what's going on at the Moon"
+
+       flaggy.AttachSubcommand(forecastCmd, 1)
+       flaggy.AttachSubcommand(moonCmd, 1)
+
+       flaggy.Parse()
+
+       if forecastCmd.Used {
+               ShowForecast(region, format, lang)
+       } else if moonCmd.Used {
+               ShowMoonPhases(format, lang)
+       } else {
+               flaggy.ShowHelpAndExit("A subcommand is required")
+       }
+}
+func sanityCheck(err error) {
+       if err != nil {
+               log.Fatal(err)
+       }
+}
diff --git a/branches/master/showforecast.go b/branches/master/showforecast.go
new file mode 100644 (file)
index 0000000..33f469b
--- /dev/null
@@ -0,0 +1,20 @@
+package main
+
+import (
+       "fmt"
+       "io"
+       "net/http"
+)
+
+// Prints the current forecast for a region in standard output
+// Required arguments: region
+// Optional arguments: format
+func ShowForecast(region string, format string, lang string) {
+        query := "https://wttr.in/" + region + "?" + format + "&lang" + lang
+        resp, err := http.Get(query)
+        sanityCheck(err)
+        defer resp.Body.Close()
+        body, err := io.ReadAll(resp.Body)
+        sanityCheck(err)
+        fmt.Printf("%s", body)
+}
diff --git a/branches/master/showmoonphases.go b/branches/master/showmoonphases.go
new file mode 100644 (file)
index 0000000..538e9a6
--- /dev/null
@@ -0,0 +1,19 @@
+package main
+
+import (
+       "fmt"
+       "io"
+       "net/http"
+)
+
+// Print the current phase of the Moon in standard output
+// Optional arguments: format
+func ShowMoonPhases(format string, lang string) {
+        query := "https://wttr.in/" + "moon" + "?" + format + "&lang=" + lang
+        resp, err := http.Get(query)
+        sanityCheck(err)
+        defer resp.Body.Close()
+        body, err := io.ReadAll(resp.Body)
+        sanityCheck(err)
+        fmt.Printf("%s\n", body)
+}
diff --git a/branches/master/version.go b/branches/master/version.go
new file mode 100644 (file)
index 0000000..d139a43
--- /dev/null
@@ -0,0 +1,19 @@
+// $TheSupernovaDuo: yuuka,v 0.1.1 2023/5/29 18:19:14 yakumo_izuru Exp $
+package main
+
+import (
+       "fmt"
+)
+
+var (
+       // Version release version
+       Version = "0.0.1"
+
+       // Commit will be overwritten automatically by the build system
+       Commit = "HEAD"
+)
+
+// FullVersion display the full version and build
+func FullVersion() string {
+       return fmt.Sprintf("%s@%s", Version, Commit)
+}
diff --git a/branches/origin-master/.gitignore b/branches/origin-master/.gitignore
new file mode 100644 (file)
index 0000000..1848005
--- /dev/null
@@ -0,0 +1 @@
+yuuka
diff --git a/branches/origin-master/COPYING b/branches/origin-master/COPYING
new file mode 100644 (file)
index 0000000..2cf0779
--- /dev/null
@@ -0,0 +1,13 @@
+Copyright (c) 2023-present Izuru Yakumo <yakumo.izuru@chaotic.ninja>
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/branches/origin-master/Makefile b/branches/origin-master/Makefile
new file mode 100644 (file)
index 0000000..c142e99
--- /dev/null
@@ -0,0 +1,19 @@
+PREFIX ?= /usr/local
+GOFLAGS ?= -v -ldflags "-w -X `go list`.Version=${VERSION} -X `go list`.Commit=${COMMIT} -X `go list`.Build=${BUILD}" -buildmode=exe
+
+VERSION ?= `git describe --abbrev=0 --tags || echo $VERSION`
+COMMIT ?= `git rev-parse --short HEAD || echo $COMMIT`
+BUILD ?= `git show -s --pretty=format:%cI`
+
+all: yuuka
+
+yuuka:
+       go build ${GOFLAGS}
+       @strip -s yuuka
+clean:
+       rm -f yuuka
+install:
+       install -Dm0755 yuuka ${DESTDIR}${PREFIX}/bin/yuuka
+uninstall:
+       rm -f ${DESTDIR}${PREFIX}/bin/yuuka
+
diff --git a/branches/origin-master/README.md b/branches/origin-master/README.md
new file mode 100644 (file)
index 0000000..081dd37
--- /dev/null
@@ -0,0 +1,2 @@
+# yuuka
+It's a [wttr](https://wttr.in) client, named after [Yuuka Kazami](https://en.touhouwiki.net/wiki/Yuuka_Kazami) from [Touhou 4: Lotus Land Story](https://en.touhouwiki.net/wiki/Lotus_Land_Story)
diff --git a/branches/origin-master/doc.go b/branches/origin-master/doc.go
new file mode 100644 (file)
index 0000000..13ae500
--- /dev/null
@@ -0,0 +1,3 @@
+// Package yuuka is yet another client for wttr.in
+// Homepage: https://suzunaan.chaotic.ninja/yuuka/
+package main
diff --git a/branches/origin-master/go.mod b/branches/origin-master/go.mod
new file mode 100644 (file)
index 0000000..106dbbd
--- /dev/null
@@ -0,0 +1,5 @@
+module marisa.chaotic.ninja/yuuka
+
+go 1.20
+
+require github.com/integrii/flaggy v1.5.2
diff --git a/branches/origin-master/go.sum b/branches/origin-master/go.sum
new file mode 100644 (file)
index 0000000..ec4c7d6
--- /dev/null
@@ -0,0 +1,5 @@
+github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
+github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/integrii/flaggy v1.5.2 h1:bWV20MQEngo4hWhno3i5Z9ISPxLPKj9NOGNwTWb/8IQ=
+github.com/integrii/flaggy v1.5.2/go.mod h1:dO13u7SYuhk910nayCJ+s1DeAAGC1THCMj1uSFmwtQ8=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
diff --git a/branches/origin-master/main.go b/branches/origin-master/main.go
new file mode 100644 (file)
index 0000000..e1c9388
--- /dev/null
@@ -0,0 +1,46 @@
+// $TheSupernovaDuo: yuuka,v 0.1.1 2023/5/29 18:19:14 yakumo_izuru Exp $
+package main
+
+import (
+       "log"
+
+       "github.com/integrii/flaggy"
+)
+var (
+       format string = "AT"
+       region string
+       lang string = "en"
+)
+func main() {
+       flaggy.SetDescription("Yuuka is yet another client for wttr.in")
+       flaggy.SetVersion(FullVersion())
+
+       forecastCmd := flaggy.NewSubcommand("forecast")
+       forecastCmd.String(&format, "f", "format", "View options")
+       forecastCmd.String(&region, "r", "region", "Where to look at")
+       forecastCmd.String(&lang, "l", "language", "Set preferred language")
+       forecastCmd.Description = "Check the current forecast of an specific location"
+
+       moonCmd := flaggy.NewSubcommand("moon")
+       moonCmd.String(&format, "f", "format", "View options")
+       moodCmd.String(&lang, "l", "language", "Set preferred language")
+       moonCmd.Description = "See what's going on at the Moon"
+
+       flaggy.AttachSubcommand(forecastCmd, 1)
+       flaggy.AttachSubcommand(moonCmd, 1)
+
+       flaggy.Parse()
+
+       if forecastCmd.Used {
+               ShowForecast(region, format, lang)
+       } else if moonCmd.Used {
+               ShowMoonPhases(format, lang)
+       } else {
+               flaggy.ShowHelpAndExit("A subcommand is required")
+       }
+}
+func sanityCheck(err error) {
+       if err != nil {
+               log.Fatal(err)
+       }
+}
diff --git a/branches/origin-master/showforecast.go b/branches/origin-master/showforecast.go
new file mode 100644 (file)
index 0000000..33f469b
--- /dev/null
@@ -0,0 +1,20 @@
+package main
+
+import (
+       "fmt"
+       "io"
+       "net/http"
+)
+
+// Prints the current forecast for a region in standard output
+// Required arguments: region
+// Optional arguments: format
+func ShowForecast(region string, format string, lang string) {
+        query := "https://wttr.in/" + region + "?" + format + "&lang" + lang
+        resp, err := http.Get(query)
+        sanityCheck(err)
+        defer resp.Body.Close()
+        body, err := io.ReadAll(resp.Body)
+        sanityCheck(err)
+        fmt.Printf("%s", body)
+}
diff --git a/branches/origin-master/showmoonphases.go b/branches/origin-master/showmoonphases.go
new file mode 100644 (file)
index 0000000..538e9a6
--- /dev/null
@@ -0,0 +1,19 @@
+package main
+
+import (
+       "fmt"
+       "io"
+       "net/http"
+)
+
+// Print the current phase of the Moon in standard output
+// Optional arguments: format
+func ShowMoonPhases(format string, lang string) {
+        query := "https://wttr.in/" + "moon" + "?" + format + "&lang=" + lang
+        resp, err := http.Get(query)
+        sanityCheck(err)
+        defer resp.Body.Close()
+        body, err := io.ReadAll(resp.Body)
+        sanityCheck(err)
+        fmt.Printf("%s\n", body)
+}
diff --git a/branches/origin-master/version.go b/branches/origin-master/version.go
new file mode 100644 (file)
index 0000000..d139a43
--- /dev/null
@@ -0,0 +1,19 @@
+// $TheSupernovaDuo: yuuka,v 0.1.1 2023/5/29 18:19:14 yakumo_izuru Exp $
+package main
+
+import (
+       "fmt"
+)
+
+var (
+       // Version release version
+       Version = "0.0.1"
+
+       // Commit will be overwritten automatically by the build system
+       Commit = "HEAD"
+)
+
+// FullVersion display the full version and build
+func FullVersion() string {
+       return fmt.Sprintf("%s@%s", Version, Commit)
+}
diff --git a/branches/origin/.gitignore b/branches/origin/.gitignore
new file mode 100644 (file)
index 0000000..1848005
--- /dev/null
@@ -0,0 +1 @@
+yuuka
diff --git a/branches/origin/COPYING b/branches/origin/COPYING
new file mode 100644 (file)
index 0000000..2cf0779
--- /dev/null
@@ -0,0 +1,13 @@
+Copyright (c) 2023-present Izuru Yakumo <yakumo.izuru@chaotic.ninja>
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/branches/origin/Makefile b/branches/origin/Makefile
new file mode 100644 (file)
index 0000000..c142e99
--- /dev/null
@@ -0,0 +1,19 @@
+PREFIX ?= /usr/local
+GOFLAGS ?= -v -ldflags "-w -X `go list`.Version=${VERSION} -X `go list`.Commit=${COMMIT} -X `go list`.Build=${BUILD}" -buildmode=exe
+
+VERSION ?= `git describe --abbrev=0 --tags || echo $VERSION`
+COMMIT ?= `git rev-parse --short HEAD || echo $COMMIT`
+BUILD ?= `git show -s --pretty=format:%cI`
+
+all: yuuka
+
+yuuka:
+       go build ${GOFLAGS}
+       @strip -s yuuka
+clean:
+       rm -f yuuka
+install:
+       install -Dm0755 yuuka ${DESTDIR}${PREFIX}/bin/yuuka
+uninstall:
+       rm -f ${DESTDIR}${PREFIX}/bin/yuuka
+
diff --git a/branches/origin/README.md b/branches/origin/README.md
new file mode 100644 (file)
index 0000000..081dd37
--- /dev/null
@@ -0,0 +1,2 @@
+# yuuka
+It's a [wttr](https://wttr.in) client, named after [Yuuka Kazami](https://en.touhouwiki.net/wiki/Yuuka_Kazami) from [Touhou 4: Lotus Land Story](https://en.touhouwiki.net/wiki/Lotus_Land_Story)
diff --git a/branches/origin/doc.go b/branches/origin/doc.go
new file mode 100644 (file)
index 0000000..13ae500
--- /dev/null
@@ -0,0 +1,3 @@
+// Package yuuka is yet another client for wttr.in
+// Homepage: https://suzunaan.chaotic.ninja/yuuka/
+package main
diff --git a/branches/origin/go.mod b/branches/origin/go.mod
new file mode 100644 (file)
index 0000000..106dbbd
--- /dev/null
@@ -0,0 +1,5 @@
+module marisa.chaotic.ninja/yuuka
+
+go 1.20
+
+require github.com/integrii/flaggy v1.5.2
diff --git a/branches/origin/go.sum b/branches/origin/go.sum
new file mode 100644 (file)
index 0000000..ec4c7d6
--- /dev/null
@@ -0,0 +1,5 @@
+github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
+github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/integrii/flaggy v1.5.2 h1:bWV20MQEngo4hWhno3i5Z9ISPxLPKj9NOGNwTWb/8IQ=
+github.com/integrii/flaggy v1.5.2/go.mod h1:dO13u7SYuhk910nayCJ+s1DeAAGC1THCMj1uSFmwtQ8=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
diff --git a/branches/origin/main.go b/branches/origin/main.go
new file mode 100644 (file)
index 0000000..e1c9388
--- /dev/null
@@ -0,0 +1,46 @@
+// $TheSupernovaDuo: yuuka,v 0.1.1 2023/5/29 18:19:14 yakumo_izuru Exp $
+package main
+
+import (
+       "log"
+
+       "github.com/integrii/flaggy"
+)
+var (
+       format string = "AT"
+       region string
+       lang string = "en"
+)
+func main() {
+       flaggy.SetDescription("Yuuka is yet another client for wttr.in")
+       flaggy.SetVersion(FullVersion())
+
+       forecastCmd := flaggy.NewSubcommand("forecast")
+       forecastCmd.String(&format, "f", "format", "View options")
+       forecastCmd.String(&region, "r", "region", "Where to look at")
+       forecastCmd.String(&lang, "l", "language", "Set preferred language")
+       forecastCmd.Description = "Check the current forecast of an specific location"
+
+       moonCmd := flaggy.NewSubcommand("moon")
+       moonCmd.String(&format, "f", "format", "View options")
+       moodCmd.String(&lang, "l", "language", "Set preferred language")
+       moonCmd.Description = "See what's going on at the Moon"
+
+       flaggy.AttachSubcommand(forecastCmd, 1)
+       flaggy.AttachSubcommand(moonCmd, 1)
+
+       flaggy.Parse()
+
+       if forecastCmd.Used {
+               ShowForecast(region, format, lang)
+       } else if moonCmd.Used {
+               ShowMoonPhases(format, lang)
+       } else {
+               flaggy.ShowHelpAndExit("A subcommand is required")
+       }
+}
+func sanityCheck(err error) {
+       if err != nil {
+               log.Fatal(err)
+       }
+}
diff --git a/branches/origin/showforecast.go b/branches/origin/showforecast.go
new file mode 100644 (file)
index 0000000..33f469b
--- /dev/null
@@ -0,0 +1,20 @@
+package main
+
+import (
+       "fmt"
+       "io"
+       "net/http"
+)
+
+// Prints the current forecast for a region in standard output
+// Required arguments: region
+// Optional arguments: format
+func ShowForecast(region string, format string, lang string) {
+        query := "https://wttr.in/" + region + "?" + format + "&lang" + lang
+        resp, err := http.Get(query)
+        sanityCheck(err)
+        defer resp.Body.Close()
+        body, err := io.ReadAll(resp.Body)
+        sanityCheck(err)
+        fmt.Printf("%s", body)
+}
diff --git a/branches/origin/showmoonphases.go b/branches/origin/showmoonphases.go
new file mode 100644 (file)
index 0000000..538e9a6
--- /dev/null
@@ -0,0 +1,19 @@
+package main
+
+import (
+       "fmt"
+       "io"
+       "net/http"
+)
+
+// Print the current phase of the Moon in standard output
+// Optional arguments: format
+func ShowMoonPhases(format string, lang string) {
+        query := "https://wttr.in/" + "moon" + "?" + format + "&lang=" + lang
+        resp, err := http.Get(query)
+        sanityCheck(err)
+        defer resp.Body.Close()
+        body, err := io.ReadAll(resp.Body)
+        sanityCheck(err)
+        fmt.Printf("%s\n", body)
+}
diff --git a/branches/origin/version.go b/branches/origin/version.go
new file mode 100644 (file)
index 0000000..d139a43
--- /dev/null
@@ -0,0 +1,19 @@
+// $TheSupernovaDuo: yuuka,v 0.1.1 2023/5/29 18:19:14 yakumo_izuru Exp $
+package main
+
+import (
+       "fmt"
+)
+
+var (
+       // Version release version
+       Version = "0.0.1"
+
+       // Commit will be overwritten automatically by the build system
+       Commit = "HEAD"
+)
+
+// FullVersion display the full version and build
+func FullVersion() string {
+       return fmt.Sprintf("%s@%s", Version, Commit)
+}
diff --git a/trunk/.gitignore b/trunk/.gitignore
new file mode 100644 (file)
index 0000000..1848005
--- /dev/null
@@ -0,0 +1 @@
+yuuka
diff --git a/trunk/COPYING b/trunk/COPYING
new file mode 100644 (file)
index 0000000..2cf0779
--- /dev/null
@@ -0,0 +1,13 @@
+Copyright (c) 2023-present Izuru Yakumo <yakumo.izuru@chaotic.ninja>
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/trunk/Makefile b/trunk/Makefile
new file mode 100644 (file)
index 0000000..c142e99
--- /dev/null
@@ -0,0 +1,19 @@
+PREFIX ?= /usr/local
+GOFLAGS ?= -v -ldflags "-w -X `go list`.Version=${VERSION} -X `go list`.Commit=${COMMIT} -X `go list`.Build=${BUILD}" -buildmode=exe
+
+VERSION ?= `git describe --abbrev=0 --tags || echo $VERSION`
+COMMIT ?= `git rev-parse --short HEAD || echo $COMMIT`
+BUILD ?= `git show -s --pretty=format:%cI`
+
+all: yuuka
+
+yuuka:
+       go build ${GOFLAGS}
+       @strip -s yuuka
+clean:
+       rm -f yuuka
+install:
+       install -Dm0755 yuuka ${DESTDIR}${PREFIX}/bin/yuuka
+uninstall:
+       rm -f ${DESTDIR}${PREFIX}/bin/yuuka
+
diff --git a/trunk/README.md b/trunk/README.md
new file mode 100644 (file)
index 0000000..081dd37
--- /dev/null
@@ -0,0 +1,2 @@
+# yuuka
+It's a [wttr](https://wttr.in) client, named after [Yuuka Kazami](https://en.touhouwiki.net/wiki/Yuuka_Kazami) from [Touhou 4: Lotus Land Story](https://en.touhouwiki.net/wiki/Lotus_Land_Story)
diff --git a/trunk/doc.go b/trunk/doc.go
new file mode 100644 (file)
index 0000000..13ae500
--- /dev/null
@@ -0,0 +1,3 @@
+// Package yuuka is yet another client for wttr.in
+// Homepage: https://suzunaan.chaotic.ninja/yuuka/
+package main
diff --git a/trunk/go.mod b/trunk/go.mod
new file mode 100644 (file)
index 0000000..106dbbd
--- /dev/null
@@ -0,0 +1,5 @@
+module marisa.chaotic.ninja/yuuka
+
+go 1.20
+
+require github.com/integrii/flaggy v1.5.2
diff --git a/trunk/go.sum b/trunk/go.sum
new file mode 100644 (file)
index 0000000..ec4c7d6
--- /dev/null
@@ -0,0 +1,5 @@
+github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
+github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/integrii/flaggy v1.5.2 h1:bWV20MQEngo4hWhno3i5Z9ISPxLPKj9NOGNwTWb/8IQ=
+github.com/integrii/flaggy v1.5.2/go.mod h1:dO13u7SYuhk910nayCJ+s1DeAAGC1THCMj1uSFmwtQ8=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
diff --git a/trunk/main.go b/trunk/main.go
new file mode 100644 (file)
index 0000000..e1c9388
--- /dev/null
@@ -0,0 +1,46 @@
+// $TheSupernovaDuo: yuuka,v 0.1.1 2023/5/29 18:19:14 yakumo_izuru Exp $
+package main
+
+import (
+       "log"
+
+       "github.com/integrii/flaggy"
+)
+var (
+       format string = "AT"
+       region string
+       lang string = "en"
+)
+func main() {
+       flaggy.SetDescription("Yuuka is yet another client for wttr.in")
+       flaggy.SetVersion(FullVersion())
+
+       forecastCmd := flaggy.NewSubcommand("forecast")
+       forecastCmd.String(&format, "f", "format", "View options")
+       forecastCmd.String(&region, "r", "region", "Where to look at")
+       forecastCmd.String(&lang, "l", "language", "Set preferred language")
+       forecastCmd.Description = "Check the current forecast of an specific location"
+
+       moonCmd := flaggy.NewSubcommand("moon")
+       moonCmd.String(&format, "f", "format", "View options")
+       moodCmd.String(&lang, "l", "language", "Set preferred language")
+       moonCmd.Description = "See what's going on at the Moon"
+
+       flaggy.AttachSubcommand(forecastCmd, 1)
+       flaggy.AttachSubcommand(moonCmd, 1)
+
+       flaggy.Parse()
+
+       if forecastCmd.Used {
+               ShowForecast(region, format, lang)
+       } else if moonCmd.Used {
+               ShowMoonPhases(format, lang)
+       } else {
+               flaggy.ShowHelpAndExit("A subcommand is required")
+       }
+}
+func sanityCheck(err error) {
+       if err != nil {
+               log.Fatal(err)
+       }
+}
diff --git a/trunk/showforecast.go b/trunk/showforecast.go
new file mode 100644 (file)
index 0000000..33f469b
--- /dev/null
@@ -0,0 +1,20 @@
+package main
+
+import (
+       "fmt"
+       "io"
+       "net/http"
+)
+
+// Prints the current forecast for a region in standard output
+// Required arguments: region
+// Optional arguments: format
+func ShowForecast(region string, format string, lang string) {
+        query := "https://wttr.in/" + region + "?" + format + "&lang" + lang
+        resp, err := http.Get(query)
+        sanityCheck(err)
+        defer resp.Body.Close()
+        body, err := io.ReadAll(resp.Body)
+        sanityCheck(err)
+        fmt.Printf("%s", body)
+}
diff --git a/trunk/showmoonphases.go b/trunk/showmoonphases.go
new file mode 100644 (file)
index 0000000..538e9a6
--- /dev/null
@@ -0,0 +1,19 @@
+package main
+
+import (
+       "fmt"
+       "io"
+       "net/http"
+)
+
+// Print the current phase of the Moon in standard output
+// Optional arguments: format
+func ShowMoonPhases(format string, lang string) {
+        query := "https://wttr.in/" + "moon" + "?" + format + "&lang=" + lang
+        resp, err := http.Get(query)
+        sanityCheck(err)
+        defer resp.Body.Close()
+        body, err := io.ReadAll(resp.Body)
+        sanityCheck(err)
+        fmt.Printf("%s\n", body)
+}
diff --git a/trunk/version.go b/trunk/version.go
new file mode 100644 (file)
index 0000000..d139a43
--- /dev/null
@@ -0,0 +1,19 @@
+// $TheSupernovaDuo: yuuka,v 0.1.1 2023/5/29 18:19:14 yakumo_izuru Exp $
+package main
+
+import (
+       "fmt"
+)
+
+var (
+       // Version release version
+       Version = "0.0.1"
+
+       // Commit will be overwritten automatically by the build system
+       Commit = "HEAD"
+)
+
+// FullVersion display the full version and build
+func FullVersion() string {
+       return fmt.Sprintf("%s@%s", Version, Commit)
+}