Improved cli command options #100
This commit is contained in:
+20
-3
@@ -10,14 +10,15 @@ use mist_api::transpiler;
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
Vec<String> args = env::args().collect();
|
Vec<String> mut args = env::args().collect();
|
||||||
if args.len() < 2 {
|
if args.len() < 2 {
|
||||||
print_usage();
|
print_usage();
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
match args[1].as_str() {
|
match args[1].as_str() {
|
||||||
"run" | "build" | "check" | "r" | "b" | "c" => {
|
"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);
|
transpiler::transpile(&root);
|
||||||
println!("");
|
println!("");
|
||||||
if builder::build(args, root) {
|
if builder::build(args, root) {
|
||||||
@@ -27,7 +28,8 @@ void main()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
"transpile" | "t" => {
|
"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);
|
transpiler::transpile(&root);
|
||||||
}
|
}
|
||||||
"init" => {
|
"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()
|
void print_usage()
|
||||||
{
|
{
|
||||||
println!("Mist - the mist compiler\n");
|
println!("Mist - the mist compiler\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user