-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy pathmain.rs
36 lines (33 loc) · 1.01 KB
/
main.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
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use std::{env::args_os, ffi::OsStr, path::Path};
fn main() {
let mut args = args_os().peekable();
let mut is_cargo = false;
let bin_name = match args
.next()
.as_deref()
.map(Path::new)
.and_then(Path::file_stem)
.and_then(OsStr::to_str)
{
Some("cargo-create-tauri-app") => {
is_cargo = true;
if args.peek().and_then(|s| s.to_str()) == Some("create-tauri-app") {
// remove the extra cargo subcommand
args.next();
Some("cargo create-tauri-app".into())
} else {
Some("cargo-create-tauri-app".into())
}
}
Some(stem) => Some(stem.to_string()),
None => None,
};
create_tauri_app::run(
args,
bin_name,
if is_cargo { Some("cargo".into()) } else { None },
);
}