feat: accept --global on :report subcommands
Every `:report` subcommand now recognizes `--global` as a scope selector that limits the report to globally-configured properties, including in JSON form via `--global --format json`. Previously this combination was rejected because `--global` was treated as an info flag, conflicting with `--format`. The shared `common.ParseReportArgs` helper now returns a `ReportArgs` struct exposing the parsed scope; each Go and bash report selects a global-only flag map when scope is global, and skips per-app verification.
This commit is contained in:
@@ -10,28 +10,38 @@ import (
|
||||
|
||||
// ReportSingleApp is an internal function that displays the ps report for one or more apps
|
||||
func ReportSingleApp(appName string, format string, infoFlag string) error {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
if appName != "--global" {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
flags := map[string]common.ReportFunc{
|
||||
"--deployed": reportDeployed,
|
||||
"--processes": reportProcesses,
|
||||
"--ps-can-scale": reportCanScale,
|
||||
"--ps-restart-policy": reportRestartPolicy,
|
||||
"--ps-computed-procfile-path": reportComputedProcfilePath,
|
||||
"--ps-global-procfile-path": reportGlobalProcfilePath,
|
||||
"--ps-procfile-path": reportProcfilePath,
|
||||
"--restore": reportRestore,
|
||||
"--running": reportRunningState,
|
||||
"--global-stop-timeout-seconds": reportGlobalStopTimeoutSeconds,
|
||||
"--computed-stop-timeout-seconds": reportComputedStopTimeoutSeconds,
|
||||
"--stop-timeout-seconds": reportStopTimeoutSeconds,
|
||||
}
|
||||
var flags map[string]common.ReportFunc
|
||||
if appName == "--global" {
|
||||
flags = map[string]common.ReportFunc{
|
||||
"--ps-global-procfile-path": reportGlobalProcfilePath,
|
||||
"--global-stop-timeout-seconds": reportGlobalStopTimeoutSeconds,
|
||||
}
|
||||
} else {
|
||||
flags = map[string]common.ReportFunc{
|
||||
"--deployed": reportDeployed,
|
||||
"--processes": reportProcesses,
|
||||
"--ps-can-scale": reportCanScale,
|
||||
"--ps-restart-policy": reportRestartPolicy,
|
||||
"--ps-computed-procfile-path": reportComputedProcfilePath,
|
||||
"--ps-global-procfile-path": reportGlobalProcfilePath,
|
||||
"--ps-procfile-path": reportProcfilePath,
|
||||
"--restore": reportRestore,
|
||||
"--running": reportRunningState,
|
||||
"--global-stop-timeout-seconds": reportGlobalStopTimeoutSeconds,
|
||||
"--computed-stop-timeout-seconds": reportComputedStopTimeoutSeconds,
|
||||
"--stop-timeout-seconds": reportStopTimeoutSeconds,
|
||||
}
|
||||
|
||||
extraFlags := addStatusFlags(appName, infoFlag)
|
||||
for flag, fn := range extraFlags {
|
||||
flags[flag] = fn
|
||||
extraFlags := addStatusFlags(appName, infoFlag)
|
||||
for flag, fn := range extraFlags {
|
||||
flags[flag] = fn
|
||||
}
|
||||
}
|
||||
|
||||
flagKeys := []string{}
|
||||
|
||||
@@ -33,11 +33,14 @@ func main() {
|
||||
case "report":
|
||||
args := flag.NewFlagSet("ps:report", flag.ExitOnError)
|
||||
format := args.String("format", "stdout", "format: [ stdout | json ]")
|
||||
osArgs, infoFlag, flagErr := common.ParseReportArgs("ps", os.Args[2:])
|
||||
reportArgs, flagErr := common.ParseReportArgs("ps", os.Args[2:])
|
||||
if flagErr == nil {
|
||||
args.Parse(osArgs)
|
||||
args.Parse(reportArgs.OSArgs)
|
||||
appName := args.Arg(0)
|
||||
err = ps.CommandReport(appName, *format, infoFlag)
|
||||
if reportArgs.IsGlobal {
|
||||
appName = "--global"
|
||||
}
|
||||
err = ps.CommandReport(appName, *format, reportArgs.InfoFlag)
|
||||
}
|
||||
case "restart":
|
||||
args := flag.NewFlagSet("ps:restart", flag.ExitOnError)
|
||||
|
||||
Reference in New Issue
Block a user