restructure subcommands

axtloss/rework-partitioning
amy 3 years ago
parent fea04b3697
commit 60127404da

@ -14,72 +14,61 @@ fn main() {
) )
.arg( .arg(
Arg::with_name("root") Arg::with_name("root")
.help("The root partition to use (only read if mode is manual)") .help("The root partition(mode = manual) or device to partition(mode = manual)")
.required_if("mode", "manual"), .required(true),
) )
.arg( .arg(
Arg::with_name("boot") Arg::with_name("boot")
.help("The boot partition to use (only read if mode is manual)") .help("The boot partition to use (only read if mode is manual)")
.required_if("mode", "manual"),
) )
.arg( .arg(
Arg::with_name("swap") Arg::with_name("swap")
.help("The swap partition to use (only read if mode is manual)") .help("The swap partition to use (only read if mode is manual)")
.required_if("mode", "manual"),
) )
.arg(
Arg::with_name("device")
.help("The device to partition (only read if mode is automatic)")
.required_if("mode", "auto"),
),
) )
.subcommand( .subcommand(
SubCommand::with_name("timezone") SubCommand::with_name("locale")
.about("Set the timezone") .about("Set locale stuff")
.arg(
Arg::with_name("keyboard")
.help("The keyboard layout to use")
.required(true),
)
.arg( .arg(
Arg::with_name("timezone") Arg::with_name("timezone")
.help("The timezone to set") .help("The timezone to use")
.required(true), .required(true),
),
) )
.subcommand(
SubCommand::with_name("locales")
.about("Set the locales")
.arg( .arg(
Arg::with_name("locales") Arg::with_name("locales")
.help("The locales to set") .help("The locales to set")
.multiple(true) .multiple(true)
.index(1) .index(3)
.required(true), .required(true),
), ),
) )
.subcommand( .subcommand(
SubCommand::with_name("hostname") SubCommand::with_name("networking")
.about("Set the hostname") .about("Set networking stuff")
.arg( .arg(
Arg::with_name("hostname") Arg::with_name("hostname")
.help("The hostname to set") .help("The hostname to use")
.required(true), .required(true),
),
) )
.subcommand(
SubCommand::with_name("ipv6")
.about("Activate IPv6")
.arg( .arg(
Arg::with_name("ipv6") Arg::with_name("wifi")
.help("If ipv6 should be activated") .help("If wifi is used (will launch nmtui if set to true)")
.required(true), .required(true),
),
) )
.subcommand(
SubCommand::with_name("rootPass")
.about("Set the root password")
.arg( .arg(
Arg::with_name("rootPass") Arg::with_name("ipv6")
.help("The root password to set") .help("Wether ipv6 should be enabled")
.required(true), .required(true),
),
) )
)
.subcommand(
SubCommand::with_name("users")
.about("Configure users")
.subcommand( .subcommand(
SubCommand::with_name("newUser") SubCommand::with_name("newUser")
.about("Create a new user") .about("Create a new user")
@ -88,33 +77,44 @@ fn main() {
.help("The username to create") .help("The username to create")
.required(true), .required(true),
) )
.arg(
Arg::with_name("hasroot")
.help("If the user should have root privileges")
.required(true),
)
.arg( .arg(
Arg::with_name("password") Arg::with_name("password")
.help("The password to set") .help("The password to set")
.required(true), .required(true),
) )
)
.subcommand( .subcommand(
SubCommand::with_name("graphical") SubCommand::with_name("rootPass")
.about("Graphical stuff (Desktop environment and Display Manager)") .about("Set the root password")
.arg( .arg(
Arg::with_name("de") Arg::with_name("rootPass")
.help("The Desktop envionment to install") .help("The root password to set")
.required(true), .required(true),
),
) )
.arg(
Arg::with_name("dm")
.help("The Display Manager to install")
.required(true),
), ),
) )
.subcommand( .subcommand(
SubCommand::with_name("flatpak") SubCommand::with_name("desktops")
.about("Flatpak") .about("Graphical stuff (Desktop environment and Display Manager)")
.arg( .arg(
Arg::with_name("flatpak") Arg::with_name("desktopsetup")
.help("If flatpak should be installed") .help("The desktop setup to use")
.required(true), .required(true),
)
.arg(
Arg::with_name("de")
.help("The Desktop envionment to install (only read if desktopsetup is set to custom)")
.required_if("desktopsetup", "custom"),
)
.arg(
Arg::with_name("dm")
.help("The Display Manager to install (only read if desktopsetup is set to custom)")
.required_if("desktopsetup", "custom"),
), ),
).get_matches(); ).get_matches();
@ -122,42 +122,51 @@ fn main() {
if let Some(app) = app.subcommand_matches("partition") { if let Some(app) = app.subcommand_matches("partition") {
let mode = app.value_of("mode").unwrap(); let mode = app.value_of("mode").unwrap();
let root = app.value_of("root").unwrap_or("none"); let root = app.value_of("root").unwrap_or("none");
let boot = app.value_of("boot").unwrap_or("none"); let boot = app.value_of("boot").unwrap_or(root);
let swap = app.value_of("swap").unwrap_or("none"); let swap = app.value_of("swap").unwrap_or("none");
let device = app.value_of("device").unwrap_or("none"); let device = if app.value_of("mode").unwrap() == "auto" {
root
} else {
"none"
};
println!("mode: {}", mode); println!("mode: {}", mode);
println!("root: {}", root); println!("root: {}", root);
println!("boot: {}", boot); println!("boot: {}", boot);
println!("swap: {}", swap); println!("swap: {}", swap);
println!("device: {}", device); println!("device: {}", device);
} else if let Some(app) = app.subcommand_matches("timezone") { } else if let Some(app) = app.subcommand_matches("locale") {
let timezone = app.value_of("timezone").unwrap(); let kbrlayout = app.value_of("keyboard").unwrap();
println!("{}", timezone); let timezn = app.value_of("timezone").unwrap();
} else if let Some(app) = app.subcommand_matches("locales") { let locale = app.values_of("locales").unwrap();
let locales = app.values_of("locales").unwrap(); println!("keyboard layout: {}", kbrlayout);
println!("{:?}", locales); println!("timezone: {}", timezn);
} else if let Some(app) = app.subcommand_matches("hostname") { println!("locales: {:?}", locale);
} else if let Some(app) = app.subcommand_matches("networking") {
let hostname = app.value_of("hostname").unwrap(); let hostname = app.value_of("hostname").unwrap();
println!("{}", hostname); let wifi = app.value_of("wifi").unwrap();
} else if let Some(app) = app.subcommand_matches("ipv6") {
let ipv6 = app.value_of("ipv6").unwrap(); let ipv6 = app.value_of("ipv6").unwrap();
println!("{}", ipv6); println!("hostname: {}", hostname);
} else if let Some(app) = app.subcommand_matches("rootPass") { println!("wifi: {}", wifi);
let root_pass = app.value_of("rootPass").unwrap(); println!("ipv6: {}", ipv6);
println!("{}", root_pass); } else if let Some(app) = app.subcommand_matches("users") {
} else if let Some(app) = app.subcommand_matches("newUser") { if let Some(app) = app.subcommand_matches("newUser") {
let username = app.value_of("username").unwrap(); let username = app.value_of("username").unwrap();
let hasroot = app.value_of("hasroot").unwrap();
let password = app.value_of("password").unwrap(); let password = app.value_of("password").unwrap();
println!("{}", username); println!("username: {}", username);
println!("{}", password); println!("hasroot: {}", hasroot);
} else if let Some(app) = app.subcommand_matches("graphical") { println!("password: {}", password);
let de = app.value_of("de").unwrap(); } else if let Some(app) = app.subcommand_matches("rootPass") {
let dm = app.value_of("dm").unwrap(); let rootpass = app.value_of("rootPass").unwrap();
println!("{}", de); println!("{}", rootpass);
println!("{}", dm); }
} else if let Some(app) = app.subcommand_matches("flatpak") { } else if let Some(app) = app.subcommand_matches("desktops") {
let flatpak = app.value_of("flatpak").unwrap(); let desktopsetup = app.value_of("desktopsetup").unwrap();
println!("{}", flatpak); let de = app.value_of("de").unwrap_or("none");
let dm = app.value_of("dm").unwrap_or("none");
println!("desktopsetup: {}", desktopsetup);
println!("de: {}", de);
println!("dm: {}", dm);
} else { } else {
println!("Running TUI installer"); println!("Running TUI installer");
} }

Loading…
Cancel
Save