This commit is contained in:
parent
0ac815f9f4
commit
817c281f3d
3 changed files with 43 additions and 40 deletions
|
@ -1,6 +1,6 @@
|
||||||
use yansi::{Color, Paint};
|
use yansi::{Color, Paint};
|
||||||
|
|
||||||
use crate::{expect_yes, install::uncomment_tag, is_root, linux::run_command, print_status};
|
use crate::{expect_yes, install::uncomment_tag, linux::is_root, linux::run_command, print_status};
|
||||||
|
|
||||||
/// Build the `kxkbrc` file for the given `layout` and `variant
|
/// Build the `kxkbrc` file for the given `layout` and `variant
|
||||||
pub fn build_kxkbrc(layout: &str, variant: Option<&str>) -> String {
|
pub fn build_kxkbrc(layout: &str, variant: Option<&str>) -> String {
|
||||||
|
|
34
src/lib.rs
Normal file
34
src/lib.rs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
pub mod args;
|
||||||
|
pub mod config;
|
||||||
|
pub mod create_iso;
|
||||||
|
pub mod install;
|
||||||
|
pub mod linux;
|
||||||
|
pub mod pkg;
|
||||||
|
pub mod print;
|
||||||
|
|
||||||
|
use std::io::Write;
|
||||||
|
|
||||||
|
use yansi::{Color, Paint};
|
||||||
|
|
||||||
|
pub fn print_status(msg: &str) {
|
||||||
|
println!(
|
||||||
|
"{} {}",
|
||||||
|
"-->".paint(Color::Red),
|
||||||
|
msg.paint(Color::Blue.bold())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Read user input and exit if the input is not "yes"
|
||||||
|
pub fn expect_yes() {
|
||||||
|
let mut input = String::new();
|
||||||
|
std::io::stdout().flush().expect("Error flushing stdout.");
|
||||||
|
std::io::stdin()
|
||||||
|
.read_line(&mut input)
|
||||||
|
.expect("Error reading input.");
|
||||||
|
let input = input.trim().to_lowercase();
|
||||||
|
|
||||||
|
if input != "yes" {
|
||||||
|
println!("Installation aborted.");
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
}
|
47
src/main.rs
47
src/main.rs
|
@ -1,28 +1,12 @@
|
||||||
use std::io::Write;
|
use navinstall::config::InstallConfig;
|
||||||
|
use navinstall::install::{
|
||||||
use config::InstallConfig;
|
drives::setup_disk_image, install, install_mnt, security::ensure_secure_boot,
|
||||||
|
};
|
||||||
mod args;
|
use navinstall::linux::is_root;
|
||||||
mod config;
|
use navinstall::print::print_config;
|
||||||
mod create_iso;
|
use navinstall::{create_iso::create_iso, expect_yes};
|
||||||
mod install;
|
|
||||||
mod linux;
|
|
||||||
mod pkg;
|
|
||||||
mod print;
|
|
||||||
use create_iso::create_iso;
|
|
||||||
use install::{drives::setup_disk_image, install, install_mnt, security::ensure_secure_boot};
|
|
||||||
use linux::is_root;
|
|
||||||
use print::print_config;
|
|
||||||
use yansi::{Color, Paint};
|
use yansi::{Color, Paint};
|
||||||
|
|
||||||
fn print_status(msg: &str) {
|
|
||||||
println!(
|
|
||||||
"{} {}",
|
|
||||||
"-->".paint(Color::Red),
|
|
||||||
msg.paint(Color::Blue.bold())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!(
|
println!(
|
||||||
"{}",
|
"{}",
|
||||||
|
@ -30,7 +14,7 @@ fn main() {
|
||||||
.paint(Color::Yellow)
|
.paint(Color::Yellow)
|
||||||
);
|
);
|
||||||
|
|
||||||
let args = args::get_args();
|
let args = navinstall::args::get_args();
|
||||||
|
|
||||||
match args.subcommand() {
|
match args.subcommand() {
|
||||||
Some(("create-iso", iso_args)) => {
|
Some(("create-iso", iso_args)) => {
|
||||||
|
@ -88,21 +72,6 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read user input and exit if the input is not "yes"
|
|
||||||
pub fn expect_yes() {
|
|
||||||
let mut input = String::new();
|
|
||||||
std::io::stdout().flush().expect("Error flushing stdout.");
|
|
||||||
std::io::stdin()
|
|
||||||
.read_line(&mut input)
|
|
||||||
.expect("Error reading input.");
|
|
||||||
let input = input.trim().to_lowercase();
|
|
||||||
|
|
||||||
if input != "yes" {
|
|
||||||
println!("Installation aborted.");
|
|
||||||
std::process::exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn read_conf(config_file: &str) -> InstallConfig {
|
pub fn read_conf(config_file: &str) -> InstallConfig {
|
||||||
let config_content = std::fs::read_to_string(config_file);
|
let config_content = std::fs::read_to_string(config_file);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue