#include #include #include namespace os { bool conditional_prompt(StringView prompt, DefaultValue fallback) { bool default_yes = fallback == DefaultYes; os::print("%s [%s] ", prompt.chars(), default_yes ? "Y/n" : "y/N"); auto line_or_error = os::File::standard_input()->read_line(); if (line_or_error.has_error()) return default_yes; auto line = line_or_error.release_value(); line.trim("\n"); if (line.view() == "y" || line.view() == "Y") return true; if (line.view() == "n" || line.view() == "N") return false; return default_yes; } }