tunasynctl: print command results with plain text instead of logging messages

This commit is contained in:
z4yx 2020-03-28 17:07:53 +08:00
parent b132192448
commit 95d6acb026

View File

@ -175,7 +175,14 @@ func listJobs(c *cli.Context) error {
}(workerID) }(workerID)
} }
for range args { for range args {
jobs = append(jobs, <-ans...) job := <-ans
if job == nil {
return cli.NewExitError(
fmt.Sprintf("Failed to correctly get information "+
"of jobs from at least one manager"),
1)
}
jobs = append(jobs, job...)
} }
genericJobs = jobs genericJobs = jobs
} }
@ -183,7 +190,7 @@ func listJobs(c *cli.Context) error {
b, err := json.MarshalIndent(genericJobs, "", " ") b, err := json.MarshalIndent(genericJobs, "", " ")
if err != nil { if err != nil {
return cli.NewExitError( return cli.NewExitError(
fmt.Sprintf("Error printing out informations: %s", err.Error()), fmt.Sprintf("Error printing out information: %s", err.Error()),
1) 1)
} }
fmt.Println(string(b)) fmt.Println(string(b))
@ -237,7 +244,7 @@ func updateMirrorSize(c *cli.Context) error {
) )
} }
logger.Infof("Successfully updated mirror size to %s", mirrorSize) fmt.Printf("Successfully updated mirror size to %s\n", mirrorSize)
return nil return nil
} }
@ -280,9 +287,9 @@ func removeWorker(c *cli.Context) error {
res := map[string]string{} res := map[string]string{}
err = json.NewDecoder(resp.Body).Decode(&res) err = json.NewDecoder(resp.Body).Decode(&res)
if res["message"] == "deleted" { if res["message"] == "deleted" {
logger.Info("Successfully removed the worker") fmt.Println("Successfully removed the worker")
} else { } else {
logger.Info("Failed to remove the worker") return cli.NewExitError("Failed to remove the worker", 1)
} }
return nil return nil
} }
@ -315,7 +322,7 @@ func flushDisabledJobs(c *cli.Context) error {
1) 1)
} }
logger.Info("Successfully flushed disabled jobs") fmt.Println("Successfully flushed disabled jobs")
return nil return nil
} }
@ -368,7 +375,7 @@ func cmdJob(cmd tunasync.CmdVerb) cli.ActionFunc {
" command: HTTP status code is not 200: %s", body), " command: HTTP status code is not 200: %s", body),
1) 1)
} }
logger.Info("Succesfully send command") fmt.Println("Successfully send the command")
return nil return nil
} }
@ -406,7 +413,7 @@ func cmdWorker(cmd tunasync.CmdVerb) cli.ActionFunc {
" command: HTTP status code is not 200: %s", body), " command: HTTP status code is not 200: %s", body),
1) 1)
} }
logger.Info("Succesfully send command") fmt.Println("Successfully send the command")
return nil return nil
} }