tauri/tooling/cli/src/main.rs
Lucas Fernandes Nogueira 4334865266
refactor(cli): rename tooling/cli.rs folder to tooling/cli (#3388)
Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
2022-02-10 17:23:10 -03:00

35 lines
838 B
Rust

// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use std::env::args_os;
use std::ffi::OsStr;
use std::path::Path;
use std::process::exit;
fn main() -> tauri_cli::Result<()> {
let mut args = args_os();
let bin_name = match args
.next()
.as_deref()
.map(Path::new)
.and_then(Path::file_stem)
.and_then(OsStr::to_str)
{
Some("cargo-tauri") => {
if args.by_ref().peekable().peek().and_then(|s| s.to_str()) == Some("tauri") {
Some("cargo tauri".into())
} else {
Some("cargo-tauri".into())
}
}
Some(stem) => Some(stem.to_string()),
None => {
eprintln!("cargo-tauri wrapper unable to read first argument");
exit(1);
}
};
tauri_cli::run(args, bin_name)
}