MCPcopy Create free account
hub / github.com/PerroEngine/Perro / prompt_text

Function prompt_text

perro_source/devtools/perro_cli/src/project.rs:143–157  ·  view source on GitHub ↗
(prompt: &str, default: Option<&str>)

Source from the content-addressed store, hash-verified

141 Ok(matches!(answer.as_str(), "y" | "yes"))
142}
143
144pub(crate) fn prompt_text(prompt: &str, default: Option<&str>) -> Result<String, String> {
145 print!("{prompt}");
146 io::stdout()
147 .flush()
148 .map_err(|err| format!("failed to flush prompt: {err}"))?;
149 let mut input = String::new();
150 io::stdin()
151 .read_line(&mut input)
152 .map_err(|err| format!("failed to read input: {err}"))?;
153 let trimmed = input.trim();
154 if trimmed.is_empty() {
155 return Ok(default.unwrap_or("").to_string());
156 }
157 Ok(trimmed.to_string())
158}
159
160pub(crate) fn scripts_command(args: &[String], cwd: &Path) -> Result<(), String> {

Callers 1

new_commandFunction · 0.85

Calls 2

flushMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected