12345678module cli910import os1112pub fn interactive() bool {13 return os.is_atty(0) != 014}1516pub fn confirm(yes bool) !bool {17 if yes {18 return true19 }20 if !interactive() {21 return error('needs --yes when not interactive')22 }23 done_working()24 eprint(' continue? [y/N] ')25 answer := os.get_line()26 eprintln('')27 return answer.trim_right('\r') in ['y', 'Y']28}29303132pub fn typed_confirm(prompt_text string, expected string) bool {33 done_working()34 eprint(' ${prompt_text} ')35 answer := os.get_line()36 eprintln('')37 return answer.trim_right('\r') == expected38}