usage_cli/lib.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#[macro_use]
extern crate log;
extern crate miette;
extern crate xx;
use std::path::PathBuf;
use miette::Result;
use cli::Cli;
mod cli;
pub mod env;
mod errors;
mod hash;
mod shebang;
#[cfg(test)]
mod test;
pub fn run(args: &[String]) -> Result<()> {
// trace!(
// "args: {:?}",
// args.iter().map(|s| s[..100].to_string()).collect_vec()
// );
// if let Some("__USAGE__") = args.get(2).map(|s| s.as_str()) {
// return split_script(&args[1]);
// } else if let Some(script) = args.get(1) {
if let Some(script) = args.get(1) {
if script.starts_with("./") || script.starts_with('/') {
let script: PathBuf = script.into();
if script.starts_with("./") && script.exists() {
return shebang::execute(&script, args);
}
}
}
Cli::run(args)
}