Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
add progress in atx-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed Nov 12, 2018
1 parent 20f2b76 commit 1793c67
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ func (server *Server) initHTTPServer() {
defer os.Remove(filepath) // release sdcard space

state := background.Get(key)
state.Status = "installing"
state.Status = "downloading"
if err := background.Wait(key); err != nil {
log.Println("http download error")
state.Error = err.Error()
Expand Down Expand Up @@ -991,11 +991,12 @@ func (server *Server) initHTTPServer() {
id := mux.Vars(r)["id"]
state := background.Get(id)
w.Header().Set("Content-Type", "application/json")
data, _ := json.Marshal(state.Progress)
renderJSON(w, map[string]interface{}{
"success": true,
"data": map[string]string{
"status": state.Status,
"description": "todo",
"description": string(data),
},
})
json.NewEncoder(w).Encode(state)
Expand Down Expand Up @@ -1440,21 +1441,26 @@ func main() {
kingpin.CommandLine.HelpFlag.Short('h')
kingpin.CommandLine.VersionFlag.Short('v')

curl := kingpin.Command("curl", "simulate curl command")
subcmd.RegisterCurl(curl)
cmdCurl := kingpin.Command("curl", "simulate curl command")
subcmd.RegisterCurl(cmdCurl)

fServer := kingpin.Command("server", "start server")
fDaemon := fServer.Flag("daemon", "daemon mode").Short('d').Bool()
fStop := fServer.Flag("stop", "stop server").Bool()
fServer.Flag("port", "listen port").Default("7912").Short('p').IntVar(&listenPort) // Create on 2017/09/12
fServer.Flag("log", "log file path when in daemon mode").StringVar(&daemonLogPath)
fTunnelServer := fServer.Flag("server", "server url").Short('t').String()
fNoUiautomator := fServer.Flag("nouia", "do not start uiautoamtor when start").Bool()
cmdServer := kingpin.Command("server", "start server")
fDaemon := cmdServer.Flag("daemon", "daemon mode").Short('d').Bool()
fStop := cmdServer.Flag("stop", "stop server").Bool()
cmdServer.Flag("port", "listen port").Default("7912").Short('p').IntVar(&listenPort) // Create on 2017/09/12
cmdServer.Flag("log", "log file path when in daemon mode").StringVar(&daemonLogPath)
fTunnelServer := cmdServer.Flag("server", "server url").Short('t').String()
fNoUiautomator := cmdServer.Flag("nouia", "do not start uiautoamtor when start").Bool()

kingpin.Command("version", "show version")

switch kingpin.Parse() {
case "curl":
subcmd.DoCurl()
return
case "version":
println(version)
return
case "server":
// continue
}
Expand Down

0 comments on commit 1793c67

Please sign in to comment.