Improved cli command options #100

This commit is contained in:
2026-07-02 18:46:45 +02:00
parent c7bf4f7131
commit 113ae54e6e
+20 -3
View File
@@ -10,14 +10,15 @@ use mist_api::transpiler;
void main()
{
Vec<String> args = env::args().collect();
Vec<String> 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<String> 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");