diff --git a/src/create_iso.rs b/src/create_iso.rs index 894542f..7842a2b 100644 --- a/src/create_iso.rs +++ b/src/create_iso.rs @@ -1,6 +1,6 @@ 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 pub fn build_kxkbrc(layout: &str, variant: Option<&str>) -> String { diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..c8b9024 --- /dev/null +++ b/src/lib.rs @@ -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); + } +} diff --git a/src/main.rs b/src/main.rs index d90dc42..2f097c7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,28 +1,12 @@ -use std::io::Write; - -use config::InstallConfig; - -mod args; -mod config; -mod create_iso; -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 navinstall::config::InstallConfig; +use navinstall::install::{ + drives::setup_disk_image, install, install_mnt, security::ensure_secure_boot, +}; +use navinstall::linux::is_root; +use navinstall::print::print_config; +use navinstall::{create_iso::create_iso, expect_yes}; use yansi::{Color, Paint}; -fn print_status(msg: &str) { - println!( - "{} {}", - "-->".paint(Color::Red), - msg.paint(Color::Blue.bold()) - ); -} - fn main() { println!( "{}", @@ -30,7 +14,7 @@ fn main() { .paint(Color::Yellow) ); - let args = args::get_args(); + let args = navinstall::args::get_args(); match args.subcommand() { 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 { let config_content = std::fs::read_to_string(config_file);