feat: v0.2.6
This commit is contained in:
46
src/main.rs
46
src/main.rs
@@ -5,33 +5,32 @@ use std::env;
|
||||
|
||||
use rust_util::util_os::get_user_home;
|
||||
|
||||
#[cfg(not(feature = "switch-go-lang"))]
|
||||
use crate::help_rs::print_help;
|
||||
#[cfg(feature = "switch-go-lang")]
|
||||
use crate::help_go::print_help;
|
||||
use crate::install::install_script;
|
||||
use crate::list::list_scripts;
|
||||
use crate::util::{
|
||||
build_script_command, get_run_script_bin_name, read_file_and_digest, run_script_command,
|
||||
};
|
||||
|
||||
#[cfg(feature = "switch-rust-lang")]
|
||||
mod help_rs;
|
||||
#[cfg(feature = "switch-go-lang")]
|
||||
mod help_go;
|
||||
#[cfg(not(feature = "switch-go-lang"))]
|
||||
mod help_rs;
|
||||
#[cfg(feature = "switch-js-lang")]
|
||||
mod help_js;
|
||||
#[cfg(feature = "switch-dart-lang")]
|
||||
mod help_dart;
|
||||
mod install;
|
||||
mod list;
|
||||
mod util;
|
||||
|
||||
#[cfg(not(feature = "switch-go-lang"))]
|
||||
const SCRIPT_TEMPLATE: &'static str = include_str!("script.template.rs");
|
||||
#[cfg(feature = "switch-go-lang")]
|
||||
const SCRIPT_TEMPLATE: &'static str = include_str!("script.template.go");
|
||||
|
||||
#[cfg(not(feature = "switch-go-lang"))]
|
||||
#[cfg(feature = "switch-rust-lang")]
|
||||
const CMD_NAME: &str = "runrs";
|
||||
#[cfg(feature = "switch-go-lang")]
|
||||
const CMD_NAME: &str = "rungo";
|
||||
#[cfg(feature = "switch-js-lang")]
|
||||
const CMD_NAME: &str = "runjs";
|
||||
#[cfg(feature = "switch-dart-lang")]
|
||||
const CMD_NAME: &str = "rundart";
|
||||
|
||||
fn main() {
|
||||
let args = env::args().skip(1).collect::<Vec<_>>();
|
||||
@@ -48,11 +47,25 @@ fn main() {
|
||||
.get(0)
|
||||
.unwrap_or_else(|| failure_and_exit!("Must assign a script file name"));
|
||||
if first_argument == "--help" || first_argument == "-h" {
|
||||
print_help();
|
||||
#[cfg(feature = "switch-rust-lang")]
|
||||
help_rs::print_help();
|
||||
#[cfg(feature = "switch-go-lang")]
|
||||
help_go::print_help();
|
||||
#[cfg(feature = "switch-js-lang")]
|
||||
help_js::print_help();
|
||||
#[cfg(feature = "switch-dart-lang")]
|
||||
help_dart::print_help();
|
||||
return;
|
||||
}
|
||||
if first_argument == "--template" || first_argument == "-t" {
|
||||
println!("{}", SCRIPT_TEMPLATE);
|
||||
#[cfg(feature = "switch-rust-lang")]
|
||||
println!("{}", include_str!("script.template.rs"));
|
||||
#[cfg(feature = "switch-go-lang")]
|
||||
println!("{}", include_str!("script.template.go"));
|
||||
#[cfg(feature = "switch-js-lang")]
|
||||
println!("{}", include_str!("script.template.js"));
|
||||
#[cfg(feature = "switch-dart-lang")]
|
||||
println!("{}", include_str!("script.template.dart"));
|
||||
return;
|
||||
}
|
||||
if first_argument == "--list" || first_argument == "-l" {
|
||||
@@ -64,10 +77,9 @@ fn main() {
|
||||
return;
|
||||
}
|
||||
|
||||
#[cfg(feature = "switch-go-lang")]
|
||||
#[cfg(any(feature = "switch-go-lang", feature = "switch-js-lang", feature = "switch-dart-lang"))]
|
||||
if true {
|
||||
// rungo, and run .go file is not supported
|
||||
failure_and_exit!("Go script should run by gorun, template for: rungo -t");
|
||||
failure_and_exit!("Only rust supports run by runrs.");
|
||||
}
|
||||
|
||||
let script_file = first_argument;
|
||||
|
||||
Reference in New Issue
Block a user