Skip to content
Snippets Groups Projects
Verified Commit 6f40e32d authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Make general.prompt optional

parent b84146ed
No related branches found
No related tags found
No related merge requests found
#[derive(Clone, Debug, Default, Deserialize, Serialize)] #[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct GeneralConfig { pub struct GeneralConfig {
pub prompt: bool, pub prompt: Option<bool>,
// Allow config to specify cookbook recipe or binary package as default // Allow config to specify cookbook recipe or binary package as default
pub repo_binary: Option<bool>, pub repo_binary: Option<bool>,
pub efi_partition_size: Option<u32>, //MiB pub efi_partition_size: Option<u32>, //MiB
...@@ -8,7 +8,7 @@ pub struct GeneralConfig { ...@@ -8,7 +8,7 @@ pub struct GeneralConfig {
impl GeneralConfig { impl GeneralConfig {
pub(super) fn merge(&mut self, other: GeneralConfig) { pub(super) fn merge(&mut self, other: GeneralConfig) {
self.prompt = other.prompt; self.prompt = other.prompt.or(self.prompt);
self.repo_binary = other.repo_binary.or(self.repo_binary); self.repo_binary = other.repo_binary.or(self.repo_binary);
self.efi_partition_size = other.efi_partition_size.or(self.efi_partition_size); self.efi_partition_size = other.efi_partition_size.or(self.efi_partition_size);
} }
......
...@@ -150,7 +150,7 @@ pub fn install_dir<P: AsRef<Path>, S: AsRef<str>>(config: Config, output_dir: P, ...@@ -150,7 +150,7 @@ pub fn install_dir<P: AsRef<Path>, S: AsRef<str>>(config: Config, output_dir: P,
//let mut context = liner::Context::new(); //let mut context = liner::Context::new();
macro_rules! prompt { macro_rules! prompt {
($dst:expr, $def:expr, $($arg:tt)*) => (if config.general.prompt { ($dst:expr, $def:expr, $($arg:tt)*) => (if config.general.prompt.unwrap_or(true) {
Err(io::Error::new( Err(io::Error::new(
io::ErrorKind::Other, io::ErrorKind::Other,
"prompt not currently supported" "prompt not currently supported"
...@@ -186,7 +186,7 @@ pub fn install_dir<P: AsRef<Path>, S: AsRef<str>>(config: Config, output_dir: P, ...@@ -186,7 +186,7 @@ pub fn install_dir<P: AsRef<Path>, S: AsRef<str>>(config: Config, output_dir: P,
// plaintext // plaintext
let password = if let Some(password) = user.password { let password = if let Some(password) = user.password {
password password
} else if config.general.prompt { } else if config.general.prompt.unwrap_or(true) {
prompt_password( prompt_password(
&format!("{}: enter password: ", username), &format!("{}: enter password: ", username),
&format!("{}: confirm password: ", username))? &format!("{}: confirm password: ", username))?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment