Commit 961983e7 authored by Jeremy Soller's avatar Jeremy Soller

Cleanup prompt macros

parent f666d064
......@@ -3,7 +3,7 @@
# General settings
[general]
# Prompt if settings are not defined
prompt = true
prompt = false
# Package settings
[packages]
......@@ -11,7 +11,11 @@ orbutils = {}
# User settings
[users.root]
password = "$argon2i$m=4096,t=10,p=1$Tnc4UVV0N00$ML9LIOujd3nmAfkAwEcSTMPqakWUF0OUiLWrIy0nGLk"
uid = 0
gid = 0
name = "root"
home = "/root"
[users.user]
password = ""
......@@ -63,14 +63,6 @@ pub fn install(config: Config) -> Result<(), String> {
let mut context = liner::Context::new();
macro_rules! prompt {
($dst:expr, $($arg:tt)*) => (if config.general.prompt {
unwrap_or_prompt($dst, &mut context, &format!($($arg)*))
} else {
Ok($dst.unwrap_or_default())
})
}
macro_rules! prompt_default {
($dst:expr, $def:expr, $($arg:tt)*) => (if config.general.prompt {
match unwrap_or_prompt($dst, &mut context, &format!($($arg)*)) {
Ok(res) => if res.is_empty() {
......@@ -105,9 +97,9 @@ pub fn install(config: Config) -> Result<(), String> {
let gid = user.gid.unwrap_or(uid);
let name = prompt_default!(user.name, username.clone(), "{}: name: ", username)?;
let home = prompt_default!(user.home, format!("/home/{}", username), "{}: home: ", username)?;
let shell = prompt_default!(user.shell, "/bin/ion".to_string(), "{}: shell: ", username)?;
let name = prompt!(user.name, username.clone(), "{}: name [{}]: ", username, username)?;
let home = prompt!(user.home, format!("/home/{}", username), "{}: home [/home/{}]: ", username, username)?;
let shell = prompt!(user.shell, "/bin/ion".to_string(), "{}: shell [/bin/ion]: ", username)?;
println!("Creating user {}:", username);
println!("\tPassword: {}", password);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment