From 6bbceb988efe493ab6abf87e30e1565118ee80f3 Mon Sep 17 00:00:00 2001 From: www Date: Sun, 29 Sep 2024 21:30:08 +0000 Subject: [PATCH 1/1] Mirrored from yuuka.git git-svn-id: https://svn.chaotic.ninja/svn/yuuka-yakumo.izuru@1 0f3ee07c-c614-0a4d-b2a1-86c95f6ad348 --- branches/master/.gitignore | 1 + branches/master/COPYING | 13 +++++++ branches/master/Makefile | 19 ++++++++++ branches/master/README.md | 2 ++ branches/master/doc.go | 3 ++ branches/master/go.mod | 5 +++ branches/master/go.sum | 5 +++ branches/master/main.go | 46 ++++++++++++++++++++++++ branches/master/showforecast.go | 20 +++++++++++ branches/master/showmoonphases.go | 19 ++++++++++ branches/master/version.go | 19 ++++++++++ branches/origin-master/.gitignore | 1 + branches/origin-master/COPYING | 13 +++++++ branches/origin-master/Makefile | 19 ++++++++++ branches/origin-master/README.md | 2 ++ branches/origin-master/doc.go | 3 ++ branches/origin-master/go.mod | 5 +++ branches/origin-master/go.sum | 5 +++ branches/origin-master/main.go | 46 ++++++++++++++++++++++++ branches/origin-master/showforecast.go | 20 +++++++++++ branches/origin-master/showmoonphases.go | 19 ++++++++++ branches/origin-master/version.go | 19 ++++++++++ branches/origin/.gitignore | 1 + branches/origin/COPYING | 13 +++++++ branches/origin/Makefile | 19 ++++++++++ branches/origin/README.md | 2 ++ branches/origin/doc.go | 3 ++ branches/origin/go.mod | 5 +++ branches/origin/go.sum | 5 +++ branches/origin/main.go | 46 ++++++++++++++++++++++++ branches/origin/showforecast.go | 20 +++++++++++ branches/origin/showmoonphases.go | 19 ++++++++++ branches/origin/version.go | 19 ++++++++++ trunk/.gitignore | 1 + trunk/COPYING | 13 +++++++ trunk/Makefile | 19 ++++++++++ trunk/README.md | 2 ++ trunk/doc.go | 3 ++ trunk/go.mod | 5 +++ trunk/go.sum | 5 +++ trunk/main.go | 46 ++++++++++++++++++++++++ trunk/showforecast.go | 20 +++++++++++ trunk/showmoonphases.go | 19 ++++++++++ trunk/version.go | 19 ++++++++++ 44 files changed, 608 insertions(+) create mode 100644 branches/master/.gitignore create mode 100644 branches/master/COPYING create mode 100644 branches/master/Makefile create mode 100644 branches/master/README.md create mode 100644 branches/master/doc.go create mode 100644 branches/master/go.mod create mode 100644 branches/master/go.sum create mode 100644 branches/master/main.go create mode 100644 branches/master/showforecast.go create mode 100644 branches/master/showmoonphases.go create mode 100644 branches/master/version.go create mode 100644 branches/origin-master/.gitignore create mode 100644 branches/origin-master/COPYING create mode 100644 branches/origin-master/Makefile create mode 100644 branches/origin-master/README.md create mode 100644 branches/origin-master/doc.go create mode 100644 branches/origin-master/go.mod create mode 100644 branches/origin-master/go.sum create mode 100644 branches/origin-master/main.go create mode 100644 branches/origin-master/showforecast.go create mode 100644 branches/origin-master/showmoonphases.go create mode 100644 branches/origin-master/version.go create mode 100644 branches/origin/.gitignore create mode 100644 branches/origin/COPYING create mode 100644 branches/origin/Makefile create mode 100644 branches/origin/README.md create mode 100644 branches/origin/doc.go create mode 100644 branches/origin/go.mod create mode 100644 branches/origin/go.sum create mode 100644 branches/origin/main.go create mode 100644 branches/origin/showforecast.go create mode 100644 branches/origin/showmoonphases.go create mode 100644 branches/origin/version.go create mode 100644 trunk/.gitignore create mode 100644 trunk/COPYING create mode 100644 trunk/Makefile create mode 100644 trunk/README.md create mode 100644 trunk/doc.go create mode 100644 trunk/go.mod create mode 100644 trunk/go.sum create mode 100644 trunk/main.go create mode 100644 trunk/showforecast.go create mode 100644 trunk/showmoonphases.go create mode 100644 trunk/version.go diff --git a/branches/master/.gitignore b/branches/master/.gitignore new file mode 100644 index 0000000..1848005 --- /dev/null +++ b/branches/master/.gitignore @@ -0,0 +1 @@ +yuuka diff --git a/branches/master/COPYING b/branches/master/COPYING new file mode 100644 index 0000000..2cf0779 --- /dev/null +++ b/branches/master/COPYING @@ -0,0 +1,13 @@ +Copyright (c) 2023-present Izuru Yakumo + +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 index 0000000..c142e99 --- /dev/null +++ b/branches/master/Makefile @@ -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 index 0000000..081dd37 --- /dev/null +++ b/branches/master/README.md @@ -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 index 0000000..13ae500 --- /dev/null +++ b/branches/master/doc.go @@ -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 index 0000000..106dbbd --- /dev/null +++ b/branches/master/go.mod @@ -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 index 0000000..ec4c7d6 --- /dev/null +++ b/branches/master/go.sum @@ -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 index 0000000..e1c9388 --- /dev/null +++ b/branches/master/main.go @@ -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(®ion, "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 index 0000000..33f469b --- /dev/null +++ b/branches/master/showforecast.go @@ -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 index 0000000..538e9a6 --- /dev/null +++ b/branches/master/showmoonphases.go @@ -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 index 0000000..d139a43 --- /dev/null +++ b/branches/master/version.go @@ -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 index 0000000..1848005 --- /dev/null +++ b/branches/origin-master/.gitignore @@ -0,0 +1 @@ +yuuka diff --git a/branches/origin-master/COPYING b/branches/origin-master/COPYING new file mode 100644 index 0000000..2cf0779 --- /dev/null +++ b/branches/origin-master/COPYING @@ -0,0 +1,13 @@ +Copyright (c) 2023-present Izuru Yakumo + +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 index 0000000..c142e99 --- /dev/null +++ b/branches/origin-master/Makefile @@ -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 index 0000000..081dd37 --- /dev/null +++ b/branches/origin-master/README.md @@ -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 index 0000000..13ae500 --- /dev/null +++ b/branches/origin-master/doc.go @@ -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 index 0000000..106dbbd --- /dev/null +++ b/branches/origin-master/go.mod @@ -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 index 0000000..ec4c7d6 --- /dev/null +++ b/branches/origin-master/go.sum @@ -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 index 0000000..e1c9388 --- /dev/null +++ b/branches/origin-master/main.go @@ -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(®ion, "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 index 0000000..33f469b --- /dev/null +++ b/branches/origin-master/showforecast.go @@ -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 index 0000000..538e9a6 --- /dev/null +++ b/branches/origin-master/showmoonphases.go @@ -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 index 0000000..d139a43 --- /dev/null +++ b/branches/origin-master/version.go @@ -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 index 0000000..1848005 --- /dev/null +++ b/branches/origin/.gitignore @@ -0,0 +1 @@ +yuuka diff --git a/branches/origin/COPYING b/branches/origin/COPYING new file mode 100644 index 0000000..2cf0779 --- /dev/null +++ b/branches/origin/COPYING @@ -0,0 +1,13 @@ +Copyright (c) 2023-present Izuru Yakumo + +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 index 0000000..c142e99 --- /dev/null +++ b/branches/origin/Makefile @@ -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 index 0000000..081dd37 --- /dev/null +++ b/branches/origin/README.md @@ -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 index 0000000..13ae500 --- /dev/null +++ b/branches/origin/doc.go @@ -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 index 0000000..106dbbd --- /dev/null +++ b/branches/origin/go.mod @@ -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 index 0000000..ec4c7d6 --- /dev/null +++ b/branches/origin/go.sum @@ -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 index 0000000..e1c9388 --- /dev/null +++ b/branches/origin/main.go @@ -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(®ion, "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 index 0000000..33f469b --- /dev/null +++ b/branches/origin/showforecast.go @@ -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 index 0000000..538e9a6 --- /dev/null +++ b/branches/origin/showmoonphases.go @@ -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 index 0000000..d139a43 --- /dev/null +++ b/branches/origin/version.go @@ -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 index 0000000..1848005 --- /dev/null +++ b/trunk/.gitignore @@ -0,0 +1 @@ +yuuka diff --git a/trunk/COPYING b/trunk/COPYING new file mode 100644 index 0000000..2cf0779 --- /dev/null +++ b/trunk/COPYING @@ -0,0 +1,13 @@ +Copyright (c) 2023-present Izuru Yakumo + +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 index 0000000..c142e99 --- /dev/null +++ b/trunk/Makefile @@ -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 index 0000000..081dd37 --- /dev/null +++ b/trunk/README.md @@ -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 index 0000000..13ae500 --- /dev/null +++ b/trunk/doc.go @@ -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 index 0000000..106dbbd --- /dev/null +++ b/trunk/go.mod @@ -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 index 0000000..ec4c7d6 --- /dev/null +++ b/trunk/go.sum @@ -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 index 0000000..e1c9388 --- /dev/null +++ b/trunk/main.go @@ -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(®ion, "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 index 0000000..33f469b --- /dev/null +++ b/trunk/showforecast.go @@ -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 index 0000000..538e9a6 --- /dev/null +++ b/trunk/showmoonphases.go @@ -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 index 0000000..d139a43 --- /dev/null +++ b/trunk/version.go @@ -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) +} -- 2.45.2