diff --git a/CHANGELOG.md b/CHANGELOG.md index f30b9f0..e255fa0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * 「--no-」のオプションの変更 * help → usage * 「同駅内徒歩」表示のバグの修正 +* 「gookit/color」という従属ソフトの取消 # 1.0.2 * ヤフー社はHTMLをちょっと更新されたから、乗換を修正する事が必要となった diff --git a/go.mod b/go.mod index 279b0e3..19ffb4c 100644 --- a/go.mod +++ b/go.mod @@ -2,10 +2,7 @@ module 076/norikae go 1.20 -require ( - github.com/gocolly/colly v1.2.0 - github.com/gookit/color v1.5.4 -) +require github.com/gocolly/colly v1.2.0 require ( github.com/PuerkitoBio/goquery v1.8.1 // indirect @@ -18,10 +15,9 @@ require ( github.com/golang/protobuf v1.3.1 // indirect github.com/kennygrant/sanitize v1.2.4 // indirect github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect + github.com/stretchr/testify v1.8.4 // indirect github.com/temoto/robotstxt v1.1.2 // indirect - github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect golang.org/x/net v0.18.0 // indirect - golang.org/x/sys v0.14.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/appengine v1.6.7 // indirect ) diff --git a/go.sum b/go.sum index cfdce0e..6c39328 100644 --- a/go.sum +++ b/go.sum @@ -19,8 +19,6 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0= -github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w= github.com/kennygrant/sanitize v1.2.4 h1:gN25/otpP5vAsO2djbMhF/LQX6R7+O1TB4yv8NzpJ3o= github.com/kennygrant/sanitize v1.2.4/go.mod h1:LGsjYYtgxbetdg5owWB2mpgUL6e2nfw2eObZ0u0qvak= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -30,10 +28,9 @@ github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d/go.mod h1:uugorj github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/temoto/robotstxt v1.1.2 h1:W2pOjSJ6SWvldyEuiFXNxz3xZ8aiWX5LbfDiOFd7Fxg= github.com/temoto/robotstxt v1.1.2/go.mod h1:+1AmkuG3IYkh1kv0d2qEB9Le88ehNO0zwOr3ujewlOo= -github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8= -github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= @@ -57,8 +54,6 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= -golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= diff --git a/src/render.go b/src/render.go index 7a0e495..023085b 100755 --- a/src/render.go +++ b/src/render.go @@ -2,49 +2,46 @@ package src import ( "fmt" - - "github.com/gookit/color" ) var r, g, b uint8 var col string func getFares(v Station, k int) { - c := color.RGB(uint8(r), uint8(g), uint8(b)).Sprint("") + for i, fare := range v.Fares { + if k != i { + continue + } - for i, fare := range v.Fares { - if k != i { continue } + col = fare.Color + fmt.Sscanf(col, "%2x%2x%2x", &r, &g, &b) + text := fare.Train - col = fare.Color - fmt.Sscanf(col, "%2x%2x%2x", &r, &g, &b) - text := fare.Train + if fare.Platform != "" { + text += "\n" + fare.Platform + } - if fare.Platform != "" { text += "\n" + fare.Platform } - c = color.RGB(uint8(r), uint8(g), uint8(b)).Sprint(text) - fmt.Println(c) - } + c := fmt.Sprintf("\x1b[38;2;%d;%d;%dm%s\x1b[0m", r, g, b, text) + fmt.Println(c) + } } func Render (route []Route) { col = "fcfcfc" - fmt.Sscanf("ff7e56", "%2x%2x%2x", &r, &g, &b) - b1 := color.RGB(uint8(r), uint8(g), uint8(b)).Sprint("早") + fmt.Sscanf("ff7e56", "%2x%2x%2x", &r, &g, &b) + b1 := fmt.Sprintf("\x1b[38;2;%d;%d;%dm%s\x1b[0m", r, g, b, "早") - fmt.Sscanf("60bddb", "%2x%2x%2x", &r, &g, &b) - b2 := color.RGB(uint8(r), uint8(g), uint8(b)).Sprint("楽") + fmt.Sscanf("60bddb", "%2x%2x%2x", &r, &g, &b) + b2 := fmt.Sprintf("\x1b[38;2;%d;%d;%dm%s\x1b[0m", r, g, b, "楽") - fmt.Sscanf("fab60a", "%2x%2x%2x", &r, &g, &b) - b3 := color.RGB(uint8(r), uint8(g), uint8(b)).Sprint("安") + fmt.Sscanf("fab60a", "%2x%2x%2x", &r, &g, &b) + b3 := fmt.Sprintf("\x1b[38;2;%d;%d;%dm%s\x1b[0m", r, g, b, "安") fmt.Sscanf(col, "%2x%2x%2x", &r, &g, &b) for key, value := range route { - color.Style{ - color.FgBlack, - color.BgMagenta, - color.OpBold, - }.Println("# ルート" + fmt.Sprintf("%d", key+1)) + fmt.Printf("\x1b[1;35m# ルート%d\x1b[0m\n", key+1) badges := "" for _, badge := range value.Badges {