main.rs 870 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2019-2021 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. use std::env::args_os;
  5. use std::ffi::OsStr;
  6. use std::path::Path;
  7. use std::process::exit;
  8. fn main() {
  9. let mut args = args_os().peekable();
  10. let bin_name = match args
  11. .next()
  12. .as_deref()
  13. .map(Path::new)
  14. .and_then(Path::file_stem)
  15. .and_then(OsStr::to_str)
  16. {
  17. Some("cargo-tauri") => {
  18. if args.peek().and_then(|s| s.to_str()) == Some("tauri") {
  19. // remove the extra cargo subcommand
  20. args.next();
  21. Some("cargo tauri".into())
  22. } else {
  23. Some("cargo-tauri".into())
  24. }
  25. }
  26. Some(stem) => Some(stem.to_string()),
  27. None => {
  28. eprintln!("cargo-tauri wrapper unable to read first argument");
  29. exit(1);
  30. }
  31. };
  32. tauri_cli::run(args, bin_name)
  33. }