getEnvPassword function
Read a password from env
, asks user via stdin when not available
Implementation
String getEnvPassword(String envKey, [String? name]) {
final String? password = dcli.env[envKey];
if (password != null) {
return password;
}
// Could not resolve password from env, ask user for password in shell
final userInput = dcli
.ask(
'Enter ${name ?? envKey} password (or provide env.$envKey):',
hidden: true,
)
.trim();
// On CI without stdin the userInput returns ""
if (userInput.isEmpty) {
throw "Password in env.$envKey is not defined and user input was empty";
}
return userInput;
}