fix: use new CallExecCommand when checking to see how help is being called

This is part of ongoing work to remove usage of the depreated NewShellCmd.
This commit is contained in:
Jose Diaz-Gonzalez
2024-02-12 00:55:16 -05:00
parent 541eb1a1bc
commit 50239b056c
16 changed files with 114 additions and 82 deletions

View File

@@ -18,8 +18,8 @@ Manage the proxy integration for an app
Additional commands:`
helpContent = `
proxy:build-config [--parallel count] [--all|<app>], (Re)builds config for a given app
proxy:clear-config [--all|<app>], Clears config for a given app
proxy:build-config [--parallel count] [--all|<app>], (Re)builds config for a given app
proxy:clear-config [--all|<app>], Clears config for a given app
proxy:disable <app>, Disable proxy for app
proxy:enable <app>, Enable proxy for app
proxy:report [<app>] [<flag>], Displays a proxy report for one or more apps
@@ -36,11 +36,13 @@ func main() {
case "proxy", "proxy:help":
usage()
case "help":
command := common.NewShellCmd(fmt.Sprintf("ps -o command= %d", os.Getppid()))
command.ShowOutput = false
output, err := command.Output()
if err == nil && strings.Contains(string(output), "--all") {
result, err := common.CallExecCommand(common.ExecCommandInput{
Command: "ps",
Args: []string{"-o", "command=", strconv.Itoa(os.Getppid())},
CaptureOutput: true,
StreamStdio: false,
})
if err == nil && strings.Contains(result.StdoutContents(), "--all") {
fmt.Println(helpContent)
} else {
fmt.Print("\n proxy, Manage the proxy integration for an app\n")