Skip to content

Commit

Permalink
Removed recursion of main
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadowbee27 committed Nov 26, 2024
1 parent dce9763 commit a2664fe
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "MC_calculator"
version = "1.3.0"
version = "1.3.1"
edition = "2021"

[dependencies]
13 changes: 1 addition & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::lib::input;
use std::process::exit;
pub mod lib {
pub mod input;
}
Expand All @@ -10,15 +9,5 @@ pub mod opperations {
mod menus;

fn main() {
println!("Enter:\n 1 => portal linking\n 2 => item operations\n 3 => quit");
let doing = input::menu_input();
match doing.trim() {
"1" => menus::portal_input(),
"2" => menus::item_operations_input(),
"3" => exit(0),
_ => {
println!("Invalid Input");
main()
}
}
menus::main_menu();
}
21 changes: 17 additions & 4 deletions src/menus.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
use crate::{input, main, opperations::item_opperations, opperations::portal_opperations};

use crate::{input, opperations::item_opperations, opperations::portal_opperations};
use std::process::exit;
pub fn main_menu(){
println!("Enter:\n 1 => portal linking\n 2 => item operations\n 3 => quit");
let doing = input::menu_input();
match doing.trim() {
"1" => portal_input(),
"2" => item_operations_input(),
"3" => exit(0),
_ => {
println!("Invalid Input");
main_menu()
}
}
}
pub fn portal_input() {
println!("Please enter to where the portal should be connected?:\n 1 => to nether \n 2 => to overworld \n 3 => menu ");
let dim = input::menu_input();
match dim.trim() {
"1" => portal_opperations::portal_to_nether(),
"2" => portal_opperations::portal_to_overworld(),
"3" => main(),
"3" => main_menu(),
_ => {
println!("Please enter a dimension");
portal_input()
Expand All @@ -27,7 +40,7 @@ pub fn item_operations_input() {
"8" => item_opperations::dchests_to_stacks(),
"9" => item_opperations::dchests_to_fullshulker(),
"10" => item_opperations::fullshulker_to_dchests(),
"11" => main(),
"11" => main_menu(),
_ => {
println!("Invalid Input");
item_operations_input()
Expand Down

0 comments on commit a2664fe

Please sign in to comment.