Power levels keep increasing widly -- to be expected

Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>

git-svn-id: file:///srv/svn/repo/yuuka/trunk@2 10373541-e681-4840-9083-43024fea98c9
This commit is contained in:
yakumo.izuru 2023-05-29 22:44:48 +00:00
parent e9bb0f129d
commit ce233a0712
5 changed files with 80 additions and 26 deletions

19
Makefile Normal file
View File

@ -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}" -tags "static_build"
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

2
go.mod
View File

@ -1,3 +1,5 @@
module marisa.chaotic.ninja/yuuka
go 1.20
require github.com/integrii/flaggy v1.5.2

5
go.sum Normal file
View File

@ -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=

55
main.go
View File

@ -1,4 +1,4 @@
// $TheSupernovaDuo: yuuka,v master 2023/5/29 17:54:15 yakumo_izuru Exp $
// $TheSupernovaDuo: yuuka,v 0.1.1 2023/5/29 18:19:14 yakumo_izuru Exp $
package main
import (
@ -6,34 +6,43 @@ import (
"io"
"log"
"net/http"
"os"
"github.com/integrii/flaggy"
)
var (
format = "?AT"
url = "https://wttr.in"
format string = "AT"
region string
)
func main() {
if len(os.Args) == 1 {
PrintUsage()
}
flaggy.SetDescription("Yuuka is a wttr.in client")
flaggy.SetVersion(FullVersion())
cmd := os.Args[1]
forecastCmd := flaggy.NewSubcommand("forecast")
forecastCmd.String(&format, "f", "format", "View options")
forecastCmd.String(&region, "r", "region", "Where to look at")
forecastCmd.Description = "Check the forecast for a specified location"
switch cmd {
case "forecast":
ShowForecast()
case "moon":
ShowMoonPhases()
flaggy.AttachSubcommand(forecastCmd, 1)
moonCmd := flaggy.NewSubcommand("moon")
moonCmd.String(&format, "f", "format", "View options")
moonCmd.Description = "Check the Moon's phases"
flaggy.AttachSubcommand(moonCmd, 1)
flaggy.ShowHelpOnUnexpectedDisable()
flaggy.Parse()
if forecastCmd.Used {
ShowForecast(region, format)
} else if moonCmd.Used {
ShowMoonPhases(format)
} else {
flaggy.ShowHelpAndExit("A subcommand is required")
}
}
func PrintUsage() {
fmt.Println("Yuuka is a wttr.in client")
fmt.Printf("\tforecast\tShow the current weather report according to your region\n")
fmt.Printf("\tmoon\tShow the current phase of the Moon\n")
}
func ShowForecast() {
query := url + format
func ShowForecast(region string, format string) {
query := "https://wttr.in/" + region + "?" + format
resp, err := http.Get(query)
sanityCheck(err)
defer resp.Body.Close()
@ -41,8 +50,8 @@ func ShowForecast() {
sanityCheck(err)
fmt.Printf("%s", body)
}
func ShowMoonPhases() {
query := url + "/Moon" + format
func ShowMoonPhases(format string) {
query := "https://wttr.in/" + "moon" + "?" + format
resp, err := http.Get(query)
sanityCheck(err)
defer resp.Body.Close()

19
version.go Normal file
View File

@ -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)
}