Skip to content

Commit

Permalink
mainをトップに持ってきたのでインストール方法が変わります
Browse files Browse the repository at this point in the history
  • Loading branch information
otiai10 committed Apr 25, 2019
1 parent f223df1 commit 2329a00
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 45 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
server/app/secret.yaml
vendor
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ amesh
# Install

```
go get -u -v github.com/otiai10/amesh/amesh
go get -u -v github.com/otiai10/amesh
```

なんかローカルで `go get` もしたくないしバイナリも持ちたくない、というひとがいたので謎にDockerコンテナで表示させるようにしました。
Expand Down
24 changes: 24 additions & 0 deletions cli/amesh.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cli

import (
"fmt"
"os"
"time"

"github.com/otiai10/amesh/lib/amesh"
"github.com/otiai10/gat/render"
)

// Amesh デフォルトのアメッシュを表示
func Amesh(r render.Renderer, geo, mask bool) error {
entry := amesh.GetEntry(time.Now())
merged, err := entry.Image(geo, mask)
if err != nil {
return err
}
if err := r.Render(os.Stdout, merged); err != nil {
return err
}
fmt.Println("#amesh", entry.URL)
return nil
}
6 changes: 3 additions & 3 deletions amesh/timelapse.go → cli/timelapse.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cli

import (
"fmt"
Expand All @@ -15,8 +15,8 @@ type snapshot struct {
Time time.Time
}

// タイムラプス表示
func timelapse(r render.Renderer, minutes, delay int, loop bool) error {
// Timelapse タイムラプス表示
func Timelapse(r render.Renderer, minutes, delay int, loop bool) error {

fmt.Printf("直近%d分間の降雨画像を取得中", minutes)

Expand Down
25 changes: 25 additions & 0 deletions cli/typhoon.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package cli

import (
"fmt"
"net/http"
"os"

"github.com/otiai10/amesh/lib/typhoon"
"github.com/otiai10/gat/render"
)

// Typhoon 台風情報を表示
func Typhoon(r render.Renderer) error {
entry, err := typhoon.GetEntry(http.DefaultClient)
if err != nil {
return err
}
img, err := entry.Image(http.DefaultClient)
if err != nil {
return err
}
r.Render(os.Stdout, img)
fmt.Println("#tenkijp", entry.Reference)
return nil
}
13 changes: 13 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module github.com/otiai10/amesh

go 1.12

require (
github.com/otiai10/chant v0.0.0-20181025063644-2735aa752660
github.com/otiai10/gat v0.0.0-20190422041449-67c01b969755
github.com/otiai10/marmoset v0.4.0
github.com/otiai10/opengraph v1.0.0
github.com/otiai10/openweathermap v0.0.0-20181017081002-254e9d1b05a2
golang.org/x/net v0.0.0-20190424112056-4829fb13d2c6
google.golang.org/appengine v1.5.0
)
33 changes: 33 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
bou.ke/monkey v1.0.1/go.mod h1:FgHuK96Rv2Nlf+0u1OOVDpCMdsWyOFmeeketDHE7LIg=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/mattn/go-sixel v0.0.0-20190320171103-a8fac8fa7d81 h1:AiRo+166RFsFNOhKhNI5szixSWPInRmBjWvfSihTn5c=
github.com/mattn/go-sixel v0.0.0-20190320171103-a8fac8fa7d81/go.mod h1:zlzhYSuMbLdRdrxfutExxGpC+Pf2uUTJ6GpVQ4LB5dc=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
github.com/otiai10/chant v0.0.0-20181025063644-2735aa752660 h1:kisuS1AKtGH7+UIKKYTDpw1aiAOK3TprjzT5dcR4tHM=
github.com/otiai10/chant v0.0.0-20181025063644-2735aa752660/go.mod h1:3vdOwedEA05C09N2EkCo+6RymMl9FQwjP7zSuofEjBQ=
github.com/otiai10/gat v0.0.0-20190422041449-67c01b969755 h1:Mj/jpguqHNencRsruk40pF5wIgRGzKIOzvFZ7zTTvGQ=
github.com/otiai10/gat v0.0.0-20190422041449-67c01b969755/go.mod h1:4KfaQUq7V21ZOGpdWaxC+djudOuhU4tvVQi8ZqrF+as=
github.com/otiai10/marmoset v0.4.0 h1:Hg59lQI7qQowBEdsAJ/+VDTEospTBzXX/A1Gsw4mlvA=
github.com/otiai10/marmoset v0.4.0/go.mod h1:t2q6dXWZ9YcFdRREDApX4bCmfQnL3isJ2dgl8ychlXg=
github.com/otiai10/mint v1.2.3/go.mod h1:YnfyPNhBvnY8bW4SGQHCs/aAFhkgySlMZbrF5U0bOVw=
github.com/otiai10/opengraph v1.0.0 h1:Fal0Qx7mBWds0z2cxMMPfZh2Ld3mW61m5BBUTybajD0=
github.com/otiai10/opengraph v1.0.0/go.mod h1:X/1XWvVWxb+8migvztlPAclxuxVCIRuLhf0xLnngZ78=
github.com/otiai10/openweathermap v0.0.0-20181017081002-254e9d1b05a2 h1:tMm4hkiJJ8q1agp5otCZsQic0+1jH5cPMBTlN2oBepU=
github.com/otiai10/openweathermap v0.0.0-20181017081002-254e9d1b05a2/go.mod h1:y4Z/bGRFIG19iQhxuUp0gXmOZU9XhPZaHDg/Hxpn34U=
github.com/soniakeys/quant v1.0.0 h1:N1um9ktjbkZVcywBVAAYpZYSHxEfJGzshHCxx/DaI0Y=
github.com/soniakeys/quant v1.0.0/go.mod h1:HI1k023QuVbD4H8i9YdfZP2munIHU4QpjsImz6Y6zds=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480 h1:O5YqonU5IWby+w98jVUG9h7zlCWCcH4RHyPVReBmhzk=
golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190424112056-4829fb13d2c6 h1:FP8hkuE6yUEaJnK7O2eTuejKWwW+Rhfj80dQ2JcKxCU=
golang.org/x/net v0.0.0-20190424112056-4829fb13d2c6/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a h1:XCr/YX7O0uxRkLq2k1ApNQMims9eCioF9UpzIPBDmuo=
golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4c=
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
55 changes: 14 additions & 41 deletions amesh/main.go → main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ import (
"fmt"
_ "image/gif"
_ "image/jpeg"
"net/http"
"os"
"time"

"github.com/otiai10/amesh/lib/amesh"
"github.com/otiai10/amesh/lib/typhoon"
"github.com/otiai10/amesh/cli"
"github.com/otiai10/gat/render"
)

Expand Down Expand Up @@ -42,47 +39,23 @@ func init() {
}

func main() {

var renderer render.Renderer
renderer := render.GetDefaultRenderer()
renderer.SetScale(0.5)
subcommand := flag.Arg(0)
switch {
case !usepix && render.ITermImageSupported():
renderer = &render.ITerm{Scale: 0.5}
case !usepix && render.SixelSupported():
renderer = &render.Sixel{Scale: 0.5}
case subcommand == "typhoon":
onerror(cli.Typhoon(renderer))
case lapse:
onerror(cli.Timelapse(renderer, minutes, delay, loop))
default:
renderer = &render.CellGrid{}
}

onerror := func(err error) {
if err == nil {
return
}
fmt.Println(err)
os.Exit(1)
}

if lapse {
err := timelapse(renderer, minutes, delay, loop)
onerror(err)
return
onerror(cli.Amesh(renderer, geo, mask))
}
}

// とりあえず
switch flag.Arg(0) {
case "typhoon":
entry, err := typhoon.GetEntry(http.DefaultClient)
onerror(err)
img, err := entry.Image(http.DefaultClient)
onerror(err)
renderer.Render(os.Stdout, img)
fmt.Println("#tenkijp", entry.Reference)
func onerror(err error) {
if err == nil {
return
default:
entry := amesh.GetEntry(time.Now())
merged, err := entry.Image(geo, mask)
onerror(err)
renderer.Render(os.Stdout, merged)
fmt.Println("#amesh", entry.URL)
}

fmt.Println(err)
os.Exit(1)
}

0 comments on commit 2329a00

Please sign in to comment.