in cli/cli.go [99:144]
func Main(stdin io.Reader, stdout io.Writer, stderr io.Writer, args []string) (exitCode int) {
if len(args) == 1 && (args[0] == "-h" || args[0] == "--help") {
printHelp(stdout)
return 0
}
app, err := loadApp(stdin, stdout, stderr)
if err != nil {
fmt.Fprintf(stderr, "ERROR: %v\n", err)
return 1
}
userOpts, err := parseOptions(args)
if err != nil {
fmt.Fprintf(stderr, "ERROR: %v\n", err)
return 1
}
credentials, err := app.AssumeRole(assumerole.AssumeRoleParameters{
ForceRefresh: userOpts.forceRefresh,
UserRole: userOpts.role,
RoleSessionName: userOpts.roleSessionName,
})
if err != nil {
fmt.Fprintf(stderr, "ERROR: %v\n", err)
return 1
}
vars := credentialsToEnv(credentials)
if len(userOpts.args) == 0 {
// Print vars to stdout
printVars(vars, stdout)
} else {
// Add AWS credentials to the environment
env := append(os.Environ(), vars...)
// execve will replace the current running process on success
if err := execute(userOpts.args[0], userOpts.args, env); err != nil {
fmt.Fprintf(stderr, "ERROR: Could not execute command: %v\n", err)
return 127
}
}
return 0
}