Skip to content

Commit 7e2d6de

Browse files
committed
the entire functionality was reviewed and tested
1 parent 5f9b0d2 commit 7e2d6de

File tree

3 files changed

+231
-210
lines changed

3 files changed

+231
-210
lines changed

src/functionality/prog_fun.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ under certain conditions; for details see https://www.gnu.org/licenses/gpl-3.0.h
2424

2525
/// validates if user has root priviliges. Terminates the program otherwise.
2626
pub fn validate_root_priviliges() {
27-
if unsafe { libc::getuid() } != 0 {
28-
eprintln!("{}", "This program requires root privileges. Please run with sudo using your current user.\nExample: sudo ./gnulinwiz".red());
29-
// exits if not root
27+
if unsafe { libc::getuid() } == 0 {
28+
eprintln!("{}", "this program is not recommended to run with root privileges. please run it with your current user.\nexample: ./gnulinwiz".red());
29+
// exits if root
3030
exit(1);
3131
}
3232
} // validate_root_priviliges()
@@ -35,39 +35,39 @@ pub fn validate_root_priviliges() {
3535
pub fn print_setup_status_success() {
3636
println!(
3737
"{}",
38-
"All set! Your GNU/Linux system is ready to use!".green()
38+
"all set! your gnu/linux system is ready to use!".green()
3939
);
4040
} // print_setup_status_success()
4141

4242
/// prints red-colored failure message if set up unseccessfully
4343
pub fn print_setup_status_failed() {
4444
println!(
4545
"{}",
46-
"Something went wrong... Please fix the reported problems and re-run the program.".red()
46+
"something went wrong... please fix the reported problems and re-run the program.".red()
4747
);
4848
} // print_setup_status_failed()
4949

5050
/// checks wether user wants to use default installation list or to enter a custom one
5151
pub fn check_sw_install_type() -> bool {
5252
println!(
5353
"{}",
54-
"Enter 0 for the default list of software or 1 to enter a custom list:".yellow()
54+
"enter any number for the default list of software or 0 to enter a custom list:".yellow()
5555
);
5656

5757
let input = read_input().trim().to_string();
5858

5959
match input.parse::<i8>() {
60-
Ok(value) if value == 1 => {
61-
println!("{}", "You chose to enter a custom list.".green());
60+
Ok(value) if value == 0 => {
61+
println!("{}", "you chose to enter a custom list.\ninstallation takes a few minutes, please wait...".green());
6262
true
6363
}
6464
Ok(_) => {
65-
println!("{}", "You chose to use the default list.".green());
65+
println!("{}", "you chose to use the default list.\ninstallation takes a few minutes, please wait...".green());
6666
false
6767
}
6868
Err(_) => {
69-
handle_error("Please enter a valid number (0 or 1).");
70-
false // Return false in case of error, or you can choose to exit
69+
handle_error("please enter a valid number (0 or 1).");
70+
false
7171
}
7272
}
7373
} // check_sw_install_type
@@ -76,15 +76,15 @@ pub fn check_sw_install_type() -> bool {
7676
fn read_input() -> String {
7777
let mut input = String::new();
7878
if let Err(error) = stdin().read_line(&mut input) {
79-
handle_error(&format!("{}{}", "Error reading input:".red(), error));
79+
handle_error(&format!("{}{}", "error reading input:".red(), error));
8080
exit(1);
8181
}
8282
input
8383
} // read_input
8484

8585
/// Handles errors by printing the error message and performing any necessary cleanup.
8686
fn handle_error(message: &str) {
87-
eprintln!("{}{}", "Error: ".red(), message);
87+
eprintln!("{}{}", "error: ".red(), message);
8888
print_setup_status_failed();
8989
exit(1);
9090
} // handle_error
@@ -94,10 +94,10 @@ pub fn set_sw_list() -> Vec<String> {
9494
let mut packages = Vec::new();
9595
let mut input = String::new();
9696

97-
println!("Enter the software packages to install (separated by spaces):");
97+
println!("enter the software packages to install (separated by spaces):");
9898
std::io::stdin()
9999
.read_line(&mut input)
100-
.expect("Failed to read line");
100+
.expect("failed to read line");
101101

102102
packages.extend(input.trim().split_whitespace().map(String::from));
103103

0 commit comments

Comments
 (0)