amalgomated/apprunner.go
func processProxyCmd(osArgs []string, fset *flag.FlagSet, cmdLibrary CmdLibrary) bool {
	// if fset is provided and is able to parse the arguments, parse the provided arguments and only consider the
	// non-flag arguments when determining whether or not the arguments constitute a proxy command
	if fset != nil && len(osArgs) > 0 {
		if err := fset.Parse(osArgs[1:]); err == nil {
			osArgs = append([]string{osArgs[0]}, fset.Args()...)
		}
	}

	if len(osArgs) <= 1 || !isProxyCmd(cmdType(osArgs[1])) {
		// not a proxy command
		return false
	}

	// get un-proxied command
	rawCmd := unproxyCmd(cmdType(osArgs[1]))
	cmd := cmdLibrary.MustNewCmd(rawCmd.Name())

	// overwrite real "os.Args" with "osArgs" before calling the in-process runner
	os.Args = append(osArgs[:1], osArgs[2:]...)

	// run command in-process. Calls into the wrapped "main" function, so it is possible/likely that the call will
	// call os.Exit and terminate the program.
	cmdLibrary.Run(cmd)

	// if previous call completed, it means that it reached the end of the wrapped main method and os.Exit was not
	// called. This is assumed to mean successful execution.
	return true
}
func processProxyCmd(osArgs []string, fset *flag.FlagSet, cmdLibrary CmdLibrary) bool {
	// if fset is provided and is able to parse the arguments, parse the provided arguments and only consider the
	// non-flag arguments when determining whether or not the arguments constitute a proxy command
	if fset != nil && len(osArgs) > 0 {
		if err := fset.Parse(osArgs[1:]); err == nil {
			osArgs = append([]string{osArgs[0]}, fset.Args()...)
		}
	}

	if len(osArgs) <= 1 || !isProxyCmd(cmdType(osArgs[1])) {
		// not a proxy command
		return false
	}

	// get un-proxied command
	rawCmd := unproxyCmd(cmdType(osArgs[1]))
	cmd := cmdLibrary.MustNewCmd(rawCmd.Name())

	// overwrite real "os.Args" with "osArgs" before calling the in-process runner
	os.Args = append(osArgs[:1], osArgs[2:]...)

	// run command in-process. Calls into the wrapped "main" function, so it is possible/likely that the call will
	// call os.Exit and terminate the program.
	cmdLibrary.Run(cmd)

	// if previous call completed, it means that it reached the end of the wrapped main method and os.Exit was not
	// called. This is assumed to mean successful execution.
	return true
}
func processProxyCmd ( osArgs [ ] string , fset * flag . FlagSet , cmdLibrary CmdLibrary ) bool { // if fset is provided and is able to parse the arguments, parse the provided arguments and only consider the // non-flag arguments when determining whether or not the arguments constitute a proxy command if fset != nil && len ( osArgs ) > 0 { if err := fset . Parse ( osArgs [ 1 : ] ) ; err == nil { osArgs = append ( [ ] string { osArgs [ 0 ] } , fset . Args ( ) ... ) } } if len ( osArgs ) <= 1 || ! isProxyCmd ( cmdType ( osArgs [ 1 ] ) ) { // not a proxy command return false } // get un-proxied command rawCmd := unproxyCmd ( cmdType ( osArgs [ 1 ] ) ) cmd := cmdLibrary . MustNewCmd ( rawCmd . Name ( ) ) // overwrite real "os.Args" with "osArgs" before calling the in-process runner os . Args = append ( osArgs [ : 1 ] , osArgs [ 2 : ] ... ) // run command in-process. Calls into the wrapped "main" function, so it is possible/likely that the call will // call os.Exit and terminate the program. cmdLibrary . Run ( cmd ) // if previous call completed, it means that it reached the end of the wrapped main method and os.Exit was not // called. This is assumed to mean successful execution. return true }
// processProxyCmd checks the second non-flag element of the provided osArgs slice (which is the first argument to the
// executable) to see if it is a proxy command. If it is, "os.Args" is set to be the non-proxy command arguments and the
// un-proxied command is run; otherwise, it is a no-op. Returns true if the command was proxied and the proxied command
// was run; false otherwise. Note that, if a proxied command is run, it is possible that the proxied command may call
// some form of "os.Exit" itself. If this is the case, then this function will be terminal and will not return a value.
processProxyCmd checks the second non - flag element of the provided osArgs slice ( which is the first argument to the executable ) to see if it is a proxy command . If it is os . Args is set to be the non - proxy command arguments and the un - proxied command is run ; otherwise it is a no - op . Returns true if the command was proxied and the proxied command was run ; false otherwise . Note that if a proxied command is run it is possible that the proxied command may call some form of os . Exit itself . If this is the case then this function will be terminal and will not return a value .