- Timestamp:
- May 4, 2025, 5:13:05 PM (5 weeks ago)
- Location:
- trunk
- Files:
-
- 5 added
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.gitignore
r1 r3 1 yuuka1 /yuuka -
trunk/COPYING
r1 r3 1 Copyright (c) 2023-present Izuru Yakumo < yakumo.izuru@chaotic.ninja>1 Copyright (c) 2023-present Izuru Yakumo <eternal-servant@yakumo.dev> 2 2 3 3 Permission to use, copy, modify, and distribute this software for any -
trunk/Makefile
r2 r3 1 GO ?= go 1 2 PREFIX ?= /usr/local 2 GOFLAGS ?= -v -ldflags "-w -X ` go list`.Version=${VERSION} -X `go list`.Commit=${COMMIT} -X `go list`.Build=${BUILD}" -tags "static_build"3 GOFLAGS ?= -v -ldflags "-w -X `${GO} list`.Version=${VERSION} -X `${GO} list`.Commit=${REV} -X `${GO} list`.Date=${DATE} -X `${GO} list`.Vendor=${VENDOR}" 3 4 4 VE RSION ?= `git describe --abbrev=0 --tags || echo $VERSION`5 COMMIT ?= `git rev-parse --short HEAD || echo $COMMIT` 6 BUILD ?= `git show -s --pretty=format:%cI`5 VENDOR ?= `uname -s` 6 VERSION ?= 0.1.2 7 REV ?= `svn info --show-item revision || git rev-list --all | wc -l` 7 8 8 9 all: yuuka 9 10 10 11 yuuka: 11 gobuild ${GOFLAGS}12 ${GO} build ${GOFLAGS} 12 13 strip -s yuuka 13 14 clean: … … 15 16 install: 16 17 install -Dm0755 yuuka ${DESTDIR}${PREFIX}/bin/yuuka 18 install -Dm0644 yuuka.1 ${DESTDIR}${PREFIX}/man/man1/yuuka.1 17 19 uninstall: 18 rm -f ${DESTDIR}${PREFIX}/bin/yuuka 19 20 rm -f ${DESTDIR}${PREFIX}/bin/yuuka ${DESTDIR}${PREFIX}/man/man1/yuuka.1 -
trunk/go.mod
r2 r3 1 module ma risa.chaotic.ninja/yuuka1 module mahou-no-mori.yakumo.dev/yuuka 2 2 3 3 go 1.20 4 4 5 5 require github.com/integrii/flaggy v1.5.2 6 7 require ( 8 github.com/inconshreveable/mousetrap v1.1.0 // indirect 9 github.com/spf13/cobra v1.9.1 // indirect 10 github.com/spf13/pflag v1.0.6 // indirect 11 ) -
trunk/go.sum
r2 r3 1 github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= 1 2 github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= 2 3 github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 4 github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= 5 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= 3 6 github.com/integrii/flaggy v1.5.2 h1:bWV20MQEngo4hWhno3i5Z9ISPxLPKj9NOGNwTWb/8IQ= 4 7 github.com/integrii/flaggy v1.5.2/go.mod h1:dO13u7SYuhk910nayCJ+s1DeAAGC1THCMj1uSFmwtQ8= 8 github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 9 github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= 10 github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0= 11 github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= 12 github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= 5 13 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 14 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 15 gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -
trunk/main.go
r2 r3 1 // $TheSupernovaDuo: yuuka,v 0.1.1 2023/5/29 18:19:14 yakumo_izuru Exp $2 1 package main 3 2 4 import ( 5 "fmt" 6 "io" 7 "log" 8 "net/http" 3 import "mahou-no-mori.yakumo.dev/yuuka/cmd" 9 4 10 "github.com/integrii/flaggy"11 )12 var (13 format string = "AT"14 region string15 )16 5 func main() { 17 flaggy.SetDescription("Yuuka is a wttr.in client") 18 flaggy.SetVersion(FullVersion()) 19 20 forecastCmd := flaggy.NewSubcommand("forecast") 21 forecastCmd.String(&format, "f", "format", "View options") 22 forecastCmd.String(®ion, "r", "region", "Where to look at") 23 forecastCmd.Description = "Check the forecast for a specified location" 24 25 flaggy.AttachSubcommand(forecastCmd, 1) 26 27 moonCmd := flaggy.NewSubcommand("moon") 28 moonCmd.String(&format, "f", "format", "View options") 29 moonCmd.Description = "Check the Moon's phases" 30 31 flaggy.AttachSubcommand(moonCmd, 1) 32 33 flaggy.ShowHelpOnUnexpectedDisable() 34 flaggy.Parse() 35 36 if forecastCmd.Used { 37 ShowForecast(region, format) 38 } else if moonCmd.Used { 39 ShowMoonPhases(format) 40 } else { 41 flaggy.ShowHelpAndExit("A subcommand is required") 42 } 6 cmd.Execute() 43 7 } 44 func ShowForecast(region string, format string) {45 query := "https://wttr.in/" + region + "?" + format46 resp, err := http.Get(query)47 sanityCheck(err)48 defer resp.Body.Close()49 body, err := io.ReadAll(resp.Body)50 sanityCheck(err)51 fmt.Printf("%s", body)52 }53 func ShowMoonPhases(format string) {54 query := "https://wttr.in/" + "moon" + "?" + format55 resp, err := http.Get(query)56 sanityCheck(err)57 defer resp.Body.Close()58 body, err := io.ReadAll(resp.Body)59 sanityCheck(err)60 fmt.Printf("%s\n", body)61 }62 func sanityCheck(err error) {63 if err != nil {64 log.Fatal(err)65 }66 }
Note:
See TracChangeset
for help on using the changeset viewer.