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:
Jose Diaz-Gonzalez
2026-04-29 04:47:15 -04:00
parent ec70e10c5d
commit 8282981361
61 changed files with 1379 additions and 518 deletions

View File

@@ -8,28 +8,41 @@ import (
// ReportSingleApp is an internal function that displays the network 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{
"--network-bind-all-interfaces": reportBindAllInterfaces,
"--network-attach-post-create": reportAttachPostCreate,
"--network-attach-post-deploy": reportAttachPostDeploy,
"--network-computed-attach-post-create": reportComputedAttachPostCreate,
"--network-computed-attach-post-deploy": reportComputedAttachPostDeploy,
"--network-computed-bind-all-interfaces": reportComputedBindAllInterfaces,
"--network-computed-initial-network": reportComputedInitialNetwork,
"--network-computed-tld": reportComputedTld,
"--network-global-attach-post-create": reportGlobalAttachPostCreate,
"--network-global-attach-post-deploy": reportGlobalAttachPostDeploy,
"--network-global-bind-all-interfaces": reportGlobalBindAllInterfaces,
"--network-global-initial-network": reportGlobalInitialNetwork,
"--network-global-tld": reportGlobalTld,
"--network-initial-network": reportInitialNetwork,
"--network-static-web-listener": reportStaticWebListener,
"--network-tld": reportTld,
"--network-web-listeners": reportWebListeners,
var flags map[string]common.ReportFunc
if appName == "--global" {
flags = map[string]common.ReportFunc{
"--network-global-attach-post-create": reportGlobalAttachPostCreate,
"--network-global-attach-post-deploy": reportGlobalAttachPostDeploy,
"--network-global-bind-all-interfaces": reportGlobalBindAllInterfaces,
"--network-global-initial-network": reportGlobalInitialNetwork,
"--network-global-tld": reportGlobalTld,
}
} else {
flags = map[string]common.ReportFunc{
"--network-bind-all-interfaces": reportBindAllInterfaces,
"--network-attach-post-create": reportAttachPostCreate,
"--network-attach-post-deploy": reportAttachPostDeploy,
"--network-computed-attach-post-create": reportComputedAttachPostCreate,
"--network-computed-attach-post-deploy": reportComputedAttachPostDeploy,
"--network-computed-bind-all-interfaces": reportComputedBindAllInterfaces,
"--network-computed-initial-network": reportComputedInitialNetwork,
"--network-computed-tld": reportComputedTld,
"--network-global-attach-post-create": reportGlobalAttachPostCreate,
"--network-global-attach-post-deploy": reportGlobalAttachPostDeploy,
"--network-global-bind-all-interfaces": reportGlobalBindAllInterfaces,
"--network-global-initial-network": reportGlobalInitialNetwork,
"--network-global-tld": reportGlobalTld,
"--network-initial-network": reportInitialNetwork,
"--network-static-web-listener": reportStaticWebListener,
"--network-tld": reportTld,
"--network-web-listeners": reportWebListeners,
}
}
flagKeys := []string{}

View File

@@ -57,11 +57,14 @@ func main() {
case "report":
args := flag.NewFlagSet("network:report", flag.ExitOnError)
format := args.String("format", "stdout", "format: [ stdout | json ]")
osArgs, infoFlag, flagErr := common.ParseReportArgs("network", os.Args[2:])
reportArgs, flagErr := common.ParseReportArgs("network", os.Args[2:])
if flagErr == nil {
args.Parse(osArgs)
args.Parse(reportArgs.OSArgs)
appName := args.Arg(0)
err = network.CommandReport(appName, *format, infoFlag)
if reportArgs.IsGlobal {
appName = "--global"
}
err = network.CommandReport(appName, *format, reportArgs.InfoFlag)
}
case "set":
args := flag.NewFlagSet("network:set", flag.ExitOnError)