-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
misc: small fix or general refactoring i did not bother commenting
- Loading branch information
1 parent
5fe6c32
commit 5601c06
Showing
3 changed files
with
34 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use std::io::{stdout, Write}; | ||
|
||
use crate::session::Error; | ||
|
||
pub(crate) fn read_arg_from_user(var_name: &str, default: Option<&str>) -> Result<String, Error> { | ||
let prompt = if let Some(def) = default { | ||
format!("{} ({}): ", var_name, def) | ||
} else { | ||
format!("{}: ", var_name) | ||
}; | ||
|
||
loop { | ||
print!("recipe.{}", &prompt); | ||
let _ = stdout().flush(); | ||
|
||
let mut input = String::new(); | ||
std::io::stdin() | ||
.read_line(&mut input) | ||
.map_err(|e| e.to_string())?; | ||
|
||
let input = input.trim(); | ||
if !input.is_empty() { | ||
return Ok(input.to_owned()); | ||
} else if let Some(def) = default { | ||
return Ok(def.to_owned()); | ||
} | ||
// keep going | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule joomla-docker
added at
4da79f