feat: add --format json support to ps:scale
The `ps:scale` command now accepts a `--format` flag that defaults to `stdout` and can be set to `json` to emit the current formation as a JSON array of process type and quantity objects, matching the JSON output the `:report` subcommands already provide. The flag only applies when displaying the current formation; it is ignored when process types are supplied for scaling. When no scale has been set for the app, the JSON output is an empty array.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package ps
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -243,12 +244,22 @@ func restorePrep() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func scaleReport(appName string) error {
|
||||
func scaleReport(appName string, format string) error {
|
||||
formations, err := getFormations(appName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if format == "json" {
|
||||
out, err := json.Marshal(formations)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
common.Log(string(out))
|
||||
return nil
|
||||
}
|
||||
|
||||
common.LogInfo1Quiet(fmt.Sprintf("Scaling for %s", appName))
|
||||
|
||||
content := []string{}
|
||||
|
||||
Reference in New Issue
Block a user