Changeset 3 in code for trunk


Ignore:
Timestamp:
May 4, 2025, 5:13:05 PM (5 weeks ago)
Author:
Izuru Yakumo
Message:

You humans are so full of yourselves. If you want to live a long life, then you should be a little more quiet.

Location:
trunk
Files:
5 added
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/.gitignore

    r1 r3  
    1 yuuka
     1/yuuka
  • trunk/COPYING

    r1 r3  
    1 Copyright (c) 2023-present Izuru Yakumo <yakumo.izuru@chaotic.ninja>
     1Copyright (c) 2023-present Izuru Yakumo <eternal-servant@yakumo.dev>
    22
    33Permission to use, copy, modify, and distribute this software for any
  • trunk/Makefile

    r2 r3  
     1GO ?= go
    12PREFIX ?= /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"
     3GOFLAGS ?= -v -ldflags "-w -X `${GO} list`.Version=${VERSION} -X `${GO} list`.Commit=${REV} -X `${GO} list`.Date=${DATE} -X `${GO} list`.Vendor=${VENDOR}"
    34
    4 VERSION ?= `git describe --abbrev=0 --tags || echo $VERSION`
    5 COMMIT ?= `git rev-parse --short HEAD || echo $COMMIT`
    6 BUILD ?= `git show -s --pretty=format:%cI`
     5VENDOR ?= `uname -s`
     6VERSION ?= 0.1.2
     7REV ?= `svn info --show-item revision || git rev-list --all | wc -l`
    78
    89all: yuuka
    910
    1011yuuka:
    11         go build ${GOFLAGS}
     12        ${GO} build ${GOFLAGS}
    1213        strip -s yuuka
    1314clean:
     
    1516install:
    1617        install -Dm0755 yuuka ${DESTDIR}${PREFIX}/bin/yuuka
     18        install -Dm0644 yuuka.1 ${DESTDIR}${PREFIX}/man/man1/yuuka.1
    1719uninstall:
    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 marisa.chaotic.ninja/yuuka
     1module mahou-no-mori.yakumo.dev/yuuka
    22
    33go 1.20
    44
    55require github.com/integrii/flaggy v1.5.2
     6
     7require (
     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  
     1github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
    12github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
    23github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
     4github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
     5github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
    36github.com/integrii/flaggy v1.5.2 h1:bWV20MQEngo4hWhno3i5Z9ISPxLPKj9NOGNwTWb/8IQ=
    47github.com/integrii/flaggy v1.5.2/go.mod h1:dO13u7SYuhk910nayCJ+s1DeAAGC1THCMj1uSFmwtQ8=
     8github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
     9github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
     10github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
     11github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
     12github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
    513golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
     14gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
     15gopkg.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 $
    21package main
    32
    4 import (
    5         "fmt"
    6         "io"
    7         "log"
    8         "net/http"
     3import "mahou-no-mori.yakumo.dev/yuuka/cmd"
    94
    10         "github.com/integrii/flaggy"
    11 )
    12 var (
    13         format string = "AT"
    14         region string
    15 )
    165func 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(&region, "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()
    437}
    44 func ShowForecast(region string, format string) {
    45         query := "https://wttr.in/" + region + "?" + format
    46         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" + "?" + format
    55         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.