123456module cli78import os910pub fn interactive() bool {11 return os.is_atty(0) != 012}1314pub fn confirm(yes bool) !bool {15 if yes {16 return true17 }18 if !interactive() {19 return error('needs --yes when not interactive')20 }21 done_working()22 eprint(' continue? [y/N] ')23 answer := os.get_line()24 eprintln('')25 return answer.trim_right('\r') in ['y', 'Y']26}272829pub fn typed_confirm(prompt_text string, expected string) bool {30 done_working()31 eprint(' ${prompt_text} ')32 answer := os.get_line()33 eprintln('')34 return answer.trim_right('\r') == expected35}