Updated main bootstrap

This commit is contained in:
2026-06-05 22:57:48 +02:00
parent c8b43a3e90
commit 1a281cd344
2 changed files with 11 additions and 11 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
use mist_analyzer; use mist_analyzer;
void main() { fn main() {
mist_analyzer::start(); mist_analyzer::start();
} }
+10 -10
View File
@@ -4,8 +4,8 @@ use std::fs;
use mist_api::builder; use mist_api::builder;
use mist_api::transpiler; use mist_api::transpiler;
void main() { fn main() {
Vec<String> args = env::args().collect(); let args Vec<String> = env::args().collect();
if (args.len() < 2) { if (args.len() < 2) {
print_usage(); print_usage();
@@ -44,7 +44,7 @@ void main() {
} }
} }
void print_usage() { fn print_usage() {
println!("Mist - the mist compiler\n"); println!("Mist - the mist compiler\n");
println!("󰖟 View our documentation! \x1b[35mhttps://mist.selimaj.dev\x1b[0m"); println!("󰖟 View our documentation! \x1b[35mhttps://mist.selimaj.dev\x1b[0m");
println!(" Follow us on github! \x1b[35mhttps://github.com/mist-go\x1b[0m\n"); println!(" Follow us on github! \x1b[35mhttps://github.com/mist-go\x1b[0m\n");
@@ -66,7 +66,7 @@ void print_usage() {
println!(" \x1b[36m mist help\x1b[0m print this message\n"); println!(" \x1b[36m mist help\x1b[0m print this message\n");
} }
void init_project(Vec<String> mut args) { fn init_project(mut args Vec<String>) {
args.remove(0); args.remove(0);
process::Command::new("cargo") process::Command::new("cargo")
@@ -77,14 +77,14 @@ void init_project(Vec<String> mut args) {
.spawn() .spawn()
.expect("Failed to run cargo").wait().expect("Unable to wait"); .expect("Failed to run cargo").wait().expect("Unable to wait");
bool is_lib = fs::metadata("src/lib.rs").is_ok(); let is_lib bool = fs::metadata("src/lib.rs").is_ok();
if (is_lib) { if (is_lib) {
fs::remove_file("src/lib.rs").expect("Failed to remove src/lib.rs"); fs::remove_file("src/lib.rs").expect("Failed to remove src/lib.rs");
fs::write("src/lib.mist", "void test() {\n}").expect("Failed to create src/lib.mist"); fs::write("src/lib.mist", "fn test() {\n}").expect("Failed to create src/lib.mist");
} else { } else {
fs::remove_file("src/main.rs").expect("Failed to remove src/main.rs"); fs::remove_file("src/main.rs").expect("Failed to remove src/main.rs");
fs::write("src/main.mist", "void main() {\n println!(\"Hello, World!\");\n}\n").expect("Failed to create src/main.mist"); fs::write("src/main.mist", "fn main() {\n println!(\"Hello, World!\");\n}\n").expect("Failed to create src/main.mist");
} }
inject_mist_target(is_lib); inject_mist_target(is_lib);
@@ -92,10 +92,10 @@ void init_project(Vec<String> mut args) {
println!("\n\x1b[34minfo\x1b[0m: Please open Cargo.toml and adjust `\x1b[35mname\x1b[0m = ` as needed, Thank you for using Mist!\n"); println!("\n\x1b[34minfo\x1b[0m: Please open Cargo.toml and adjust `\x1b[35mname\x1b[0m = ` as needed, Thank you for using Mist!\n");
} }
void inject_mist_target(bool is_lib) { fn inject_mist_target(is_lib bool) {
String toml_content = fs::read_to_string("Cargo.toml").expect("Failed to read Cargo.toml"); let toml_content String = fs::read_to_string("Cargo.toml").expect("Failed to read Cargo.toml");
str* inject = if (is_lib) { let inject *str = if (is_lib) {
"\n[lib]\nname = \"my_lib\"\npath = \".mist/src/lib.rs\"\n" "\n[lib]\nname = \"my_lib\"\npath = \".mist/src/lib.rs\"\n"
} else { } else {
"\n[[bin]]\nname = \"my_bin\"\npath = \".mist/src/main.rs\"\n" "\n[[bin]]\nname = \"my_bin\"\npath = \".mist/src/main.rs\"\n"