Function broot::cli::ask_authorization
source · pub fn ask_authorization() -> Result<bool, ProgramError>
Expand description
wait for user input, return true
if they didn’t answer ‘n’
Examples found in repository?
src/shell_install/mod.rs (line 184)
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
fn can_do(&mut self) -> Result<bool, ProgramError> {
if let Some(authorization) = self.authorization {
return Ok(authorization);
}
let refused_path = get_refused_path();
if refused_path.exists() {
debug!("User already refused the installation");
return Ok(false);
}
self.skin.print_text(MD_INSTALL_REQUEST);
let proceed = cli::ask_authorization()?;
debug!("proceed: {:?}", proceed);
self.authorization = Some(proceed);
if !proceed {
write_state(ShellInstallState::Refused)?;
self.skin.print_text(MD_INSTALL_CANCELLED);
}
Ok(proceed)
}