2
0
mirror of https://github.com/skanehira/tson synced 2024-11-03 09:40:22 +00:00

improve run function

This commit is contained in:
skanehira 2019-11-02 17:40:28 +09:00
parent cc83ce3052
commit 18abd7e204

19
main.go
View File

@ -46,33 +46,30 @@ func init() {
}
func run() int {
var i interface{}
if *url != "" {
resp, err := http.Get(*url)
if err != nil {
return printError(err)
}
i, err := gui.UnMarshalJSON(resp.Body)
i, err = gui.UnMarshalJSON(resp.Body)
if err != nil {
return printError(err)
}
if err := gui.New().Run(i); err != nil {
return printError(err)
}
return 0
}
if !terminal.IsTerminal(0) {
i, err := gui.UnMarshalJSON(os.Stdin)
var err error
i, err = gui.UnMarshalJSON(os.Stdin)
if err != nil {
return printError(err)
}
}
if err := gui.New().Run(i); err != nil {
log.Println(err)
return 1
}
if err := gui.New().Run(i); err != nil {
log.Println(err)
return 1
}
return 0
}