From 113ae54e6e9a973064faf1532fec37c3d3c49d7f Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Thu, 2 Jul 2026 18:46:45 +0200 Subject: [PATCH] Improved cli command options #100 --- src/main.mist | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main.mist b/src/main.mist index 3f28e86..2fafbe0 100644 --- a/src/main.mist +++ b/src/main.mist @@ -10,14 +10,15 @@ use mist_api::transpiler; void main() { - Vec args = env::args().collect(); + Vec mut args = env::args().collect(); if args.len() < 2 { print_usage(); process::exit(1); } match args[1].as_str() { "run" | "build" | "check" | "r" | "b" | "c" => { - let root = env::current_dir().expect("Unable to find project root"); + let mut root = env::current_dir().expect("Unable to find project root"); + modify_args(&mut args, &mut root); transpiler::transpile(&root); println!(""); if builder::build(args, root) { @@ -27,7 +28,8 @@ void main() } } "transpile" | "t" => { - let root = env::current_dir().expect("Unable to find project root"); + let mut root = env::current_dir().expect("Unable to find project root"); + modify_args(&mut args, &mut root); transpiler::transpile(&root); } "init" => { @@ -47,6 +49,21 @@ void main() } } +void modify_args(Vec mut& args, std::path::PathBuf mut& root) +{ + if let Some(path_arg) = args.get(2) { + if path_arg == "--path" { + if args.len() > 3 { + let path_arg = args[3].clone(); + *root = root.join(&path_arg); + args.remove(2); + args.remove(2); + args.push(format!("--manifest-path={}/Cargo.toml", root.display())); + } + } + } +} + void print_usage() { println!("Mist - the mist compiler\n");