override fun constructCommandLine()

in jetbrains-core/src/software/aws/toolkits/jetbrains/services/lambda/steps/SamRunnerStep.kt [25:74]


    override fun constructCommandLine(context: Context): GeneralCommandLine {
        val builtLambda = context.getRequiredAttribute(BuildLambda.BUILT_LAMBDA)
        val totalEnvVars = settings.environmentVariables +
            settings.connection.credentials.resolveCredentials().toEnvironmentVariables() +
            settings.connection.region.toEnvironmentVariables()

        val commandLine = getCli()
            .withParameters("local")
            .withParameters("invoke")
            .apply {
                if (settings is TemplateSettings) {
                    withParameters(settings.logicalId)
                }
            }
            .withParameters("--template")
            .withParameters(builtLambda.templateLocation.toString())
            .withParameters("--event")
            .withParameters(createEventFile())
            .withEnvironment(totalEnvVars)
            .withEnvironment("PYTHONUNBUFFERED", "1") // Force SAM to not buffer stdout/stderr so it gets shown in IDE

        if (debug) {
            val debugExtension = settings.resolveDebuggerSupport()
            val debugPorts = context.getRequiredAttribute(DEBUG_PORTS)
            commandLine.addParameters(debugExtension.samArguments(debugPorts))
            debugPorts.forEach {
                commandLine.withParameters("--debug-port").withParameters(it.toString())
            }
        }

        val samOptions = settings.samOptions
        if (samOptions.skipImagePull) {
            commandLine.withParameters("--skip-pull-image")
        }

        samOptions.dockerNetwork?.let {
            if (it.isNotBlank()) {
                commandLine.withParameters("--docker-network")
                    .withParameters(it.trim())
            }
        }

        samOptions.additionalLocalArgs?.let {
            if (it.isNotBlank()) {
                commandLine.withParameters(*it.split(" ").toTypedArray())
            }
        }

        return commandLine
    }