Skip to content

Commit

Permalink
tunasynctl: print command results with plain text instead of logging …
Browse files Browse the repository at this point in the history
…messages
  • Loading branch information
z4yx committed Mar 28, 2020
1 parent b132192 commit 95d6acb
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions cmd/tunasynctl/tunasynctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,22 @@ func listJobs(c *cli.Context) error {
}(workerID)
}
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
}

b, err := json.MarshalIndent(genericJobs, "", " ")
if err != nil {
return cli.NewExitError(
fmt.Sprintf("Error printing out informations: %s", err.Error()),
fmt.Sprintf("Error printing out information: %s", err.Error()),
1)
}
fmt.Println(string(b))
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -280,9 +287,9 @@ func removeWorker(c *cli.Context) error {
res := map[string]string{}
err = json.NewDecoder(resp.Body).Decode(&res)
if res["message"] == "deleted" {
logger.Info("Successfully removed the worker")
fmt.Println("Successfully removed the worker")
} else {
logger.Info("Failed to remove the worker")
return cli.NewExitError("Failed to remove the worker", 1)
}
return nil
}
Expand Down Expand Up @@ -315,7 +322,7 @@ func flushDisabledJobs(c *cli.Context) error {
1)
}

logger.Info("Successfully flushed disabled jobs")
fmt.Println("Successfully flushed disabled jobs")
return nil
}

Expand Down Expand Up @@ -368,7 +375,7 @@ func cmdJob(cmd tunasync.CmdVerb) cli.ActionFunc {
" command: HTTP status code is not 200: %s", body),
1)
}
logger.Info("Succesfully send command")
fmt.Println("Successfully send the command")

return nil
}
Expand Down Expand Up @@ -406,7 +413,7 @@ func cmdWorker(cmd tunasync.CmdVerb) cli.ActionFunc {
" command: HTTP status code is not 200: %s", body),
1)
}
logger.Info("Succesfully send command")
fmt.Println("Successfully send the command")

return nil
}
Expand Down

0 comments on commit 95d6acb

Please sign in to comment.