MCPcopy Index your code
hub / github.com/keploy/keploy / ExtractCommandFromArgs

Function ExtractCommandFromArgs

utils/utils.go:551–573  ·  view source on GitHub ↗

FindDockerCmd checks if the cli is related to docker or not, it also returns if it is a docker compose file ExtractCommandFromArgs parses os.Args to find the value of -c or --command flag. Returns empty string if not found.

(args []string)

Source from the content-addressed store, hash-verified

549// ExtractCommandFromArgs parses os.Args to find the value of -c or --command flag.
550// Returns empty string if not found.
551func ExtractCommandFromArgs(args []string) string {
552 for i := 0; i < len(args); i++ {
553 arg := args[i]
554
555 // Check for -c or --command
556 if arg == "-c" || arg == "--command" {
557 // Next argument is the command value
558 if i+1 < len(args) {
559 return args[i+1]
560 }
561 return ""
562 }
563
564 // Check for -c=value or --command=value format
565 if len(arg) > 3 && arg[:3] == "-c=" {
566 return arg[3:]
567 }
568 if len(arg) > 10 && arg[:10] == "--command=" {
569 return arg[10:]
570 }
571 }
572 return ""
573}
574
575// FindDockerCmd checks if the cli is related to docker or not, it also returns if it is a docker compose file
576func FindDockerCmd(cmd string) CmdType {

Callers 1

ShouldReexecWithSudoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected