Skip to content

Commit

Permalink
add function for choice
Browse files Browse the repository at this point in the history
  • Loading branch information
0xhenrique committed Nov 13, 2023
1 parent 576f70c commit f3459a4
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
7 changes: 7 additions & 0 deletions Cargo.lock

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

9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "haki"
version = "0.1.0"
edition = "2021"
authors = ["Dave", "Henrique"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
53 changes: 53 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
use std::io;
use std::num::ParseIntError;

fn main() {
let mut parsed_input: Result<u32, ParseIntError>;

print_options();

while {
let mut input = String::new();
io::stdin().read_line(&mut input).expect("Failed to read line");

parsed_input = input.trim().parse();
let parsed_input_clone = parsed_input.clone();

parsed_input.is_err() || !(1..=10).contains(&parsed_input_clone.unwrap())
} {
println!("Invalid input. Please enter a valid number between 1 and 10:");
print_options();
}

match parsed_input.unwrap() {
1 => install_pinia(),
2 => install_husky(),
3 => install_jenkins(),
4 => install_jotai(),
_ => unreachable!(),
}
}

fn print_options() {
println!("What do you want to install?");
println!("1 - Pinia");
println!("2 - Husky");
println!("3 - Jenkins");
println!("4 - Jotai");
}

fn install_pinia() {
println!("Installing Pinia...");
}

fn install_husky() {
println!("Installing Husky...");
}

fn install_jenkins() {
println!("Installing Jenkins...");
}

fn install_jotai() {
println!("Installing Jotai...");
}

0 comments on commit f3459a4

Please sign in to comment.