get rid of 'set' subcommand, works without it

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

@ -0,0 +1,9 @@
pub fn partition(root: &str, boot: &str, swap: &str, mode: &str, device: &str) {
if mode == "manual" {
println!("Using {} as root partition", root);
println!("Using {} as boot partition", boot);
println!("Using {} as swap partition", swap);
} else {
println!("automatically partitioning {}", device);
}
}

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

Loading…
Cancel
Save