read and output specified values

axtloss/rework-partitioning
amy 3 years ago
parent 6ae8149647
commit 3422c43ef3

@ -1,4 +1,4 @@
use clap::{App, AppSettings, Arg, ArgMatches, ArgSettings, Shell, SubCommand}; use clap::{App, Arg, SubCommand};
fn main() { fn main() {
let app = App::new("jade") let app = App::new("jade")
@ -7,114 +7,156 @@ fn main() {
.subcommand( .subcommand(
SubCommand::with_name("set") SubCommand::with_name("set")
.about("Sets a value for installation") .about("Sets a value for installation")
.subcommand( .subcommand(
SubCommand::with_name("partition") SubCommand::with_name("partition")
.about("Partition the install destination") .about("Partition the install destination")
.arg( .arg(
Arg::with_name("mode") Arg::with_name("mode")
.help("If jade should automatically partition (mode = auto) or the user manually partitioned it (mode = manual)") .help("If jade should automatically partition (mode = auto) or the user manually partitioned it (mode = manual)")
.required(true), .required(true),
) )
.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 to use (only read if mode is manual)")
.required_if("mode", "manual"), .required_if("mode", "manual"),
) )
.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"), .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"), .required_if("mode", "manual"),
), ),
) )
.subcommand( .subcommand(
SubCommand::with_name("timezone") SubCommand::with_name("timezone")
.about("Set the timezone") .about("Set the timezone")
.arg( .arg(
Arg::with_name("timezone") Arg::with_name("timezone")
.help("The timezone to set") .help("The timezone to set")
.required(true), .required(true),
), ),
) )
.subcommand( .subcommand(
SubCommand::with_name("locales") SubCommand::with_name("locales")
.about("Set the 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(1)
.required(true), .required(true),
), ),
) )
.subcommand( .subcommand(
SubCommand::with_name("hostname") SubCommand::with_name("hostname")
.about("Set the hostname") .about("Set the hostname")
.arg( .arg(
Arg::with_name("hostname") Arg::with_name("hostname")
.help("The hostname to set") .help("The hostname to set")
.required(true), .required(true),
), ),
) )
.subcommand( .subcommand(
SubCommand::with_name("ipv6") SubCommand::with_name("ipv6")
.about("Activate IPv6") .about("Activate IPv6")
.arg( .arg(
Arg::with_name("ipv6") Arg::with_name("ipv6")
.help("If ipv6 should be activated") .help("If ipv6 should be activated")
.required(true), .required(true),
), ),
) )
.subcommand( .subcommand(
SubCommand::with_name("rootPass") SubCommand::with_name("rootPass")
.about("Set the root password") .about("Set the root password")
.arg( .arg(
Arg::with_name("rootPass") Arg::with_name("rootPass")
.help("The root password to set") .help("The root password to set")
.required(true), .required(true),
), ),
) )
.subcommand( .subcommand(
SubCommand::with_name("newUser") SubCommand::with_name("newUser")
.about("Create a new user") .about("Create a new user")
.arg( .arg(
Arg::with_name("username") Arg::with_name("username")
.help("The username to create") .help("The username to create")
.required(true), .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("graphical")
.about("Graphical stuff (Desktop environment and Display Manager)") .about("Graphical stuff (Desktop environment and Display Manager)")
.arg( .arg(
Arg::with_name("de") Arg::with_name("de")
.help("The Desktop envionment to install") .help("The Desktop envionment to install")
.required(true), .required(true),
) )
.arg( .arg(
Arg::with_name("dm") Arg::with_name("dm")
.help("The Display Manager to install") .help("The Display Manager to install")
.required(true), .required(true),
), ),
) )
.subcommand( .subcommand(
SubCommand::with_name("flatpak") SubCommand::with_name("flatpak")
.about("Flatpak") .about("Flatpak")
.arg( .arg(
Arg::with_name("flatpak") Arg::with_name("flatpak")
.help("If flatpak should be installed") .help("If flatpak should be installed")
.required(true), .required(true),
), ),
) )
) ).get_matches();
.get_matches();
if let Some(app) = app.subcommand_matches("set") {
if let Some(app) = app.subcommand_matches("partition") {
let mode = app.value_of("mode").unwrap();
let root = app.value_of("root").unwrap_or("none");
let boot = app.value_of("boot").unwrap_or("none");
let swap = app.value_of("swap").unwrap_or("none");
println!("mode: {}", mode);
println!("root: {}", root);
println!("boot: {}", boot);
println!("swap: {}", swap);
} else if let Some(app) = app.subcommand_matches("timezone") {
let timezone = app.value_of("timezone").unwrap();
println!("{}", timezone);
} else if let Some(app) = app.subcommand_matches("locales") {
let locales = app.values_of("locales").unwrap();
println!("{:?}", locales);
} else if let Some(app) = app.subcommand_matches("hostname") {
let hostname = app.value_of("hostname").unwrap();
println!("{}", hostname);
} else if let Some(app) = app.subcommand_matches("ipv6") {
let ipv6 = app.value_of("ipv6").unwrap();
println!("{}", ipv6);
} else if let Some(app) = app.subcommand_matches("rootPass") {
let root_pass = app.value_of("rootPass").unwrap();
println!("{}", root_pass);
} else if let Some(app) = app.subcommand_matches("newUser") {
let username = app.value_of("username").unwrap();
let password = app.value_of("password").unwrap();
println!("{}", username);
println!("{}", password);
} else if let Some(app) = app.subcommand_matches("graphical") {
let de = app.value_of("de").unwrap();
let dm = app.value_of("dm").unwrap();
println!("{}", de);
println!("{}", dm);
} else if let Some(app) = app.subcommand_matches("flatpak") {
let flatpak = app.value_of("flatpak").unwrap();
println!("{}", flatpak);
}
} else {
println!("Running TUI installer");
}
} }

Loading…
Cancel
Save