mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-19 00:13:01 +08:00
Merge pull request #2044 from 21pages/fix-command-line
fix command line support
This commit is contained in:
commit
23676e15ed
@ -51,24 +51,29 @@ fn execute(path: PathBuf, args: Vec<String>) {
|
||||
.expect(&format!("failed to execute {:?}", exe_name));
|
||||
}
|
||||
|
||||
fn is_setup(name: &str) -> bool {
|
||||
name.to_lowercase().ends_with("install.exe") || name.to_lowercase().ends_with("安装.exe")
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let is_setup = is_setup(
|
||||
&std::env::current_exe()
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.to_string(),
|
||||
);
|
||||
let reader = BinaryReader::default();
|
||||
if let Some(exe) = setup(reader, None, is_setup) {
|
||||
let args = if is_setup {
|
||||
vec!["--install".to_owned()]
|
||||
let mut args = Vec::new();
|
||||
let mut arg_exe = Default::default();
|
||||
let mut i = 0;
|
||||
for arg in std::env::args() {
|
||||
if i == 0 {
|
||||
arg_exe = arg.clone();
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
args.push(arg);
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
let click_setup = args.is_empty() && arg_exe.to_lowercase().ends_with("install.exe");
|
||||
|
||||
let reader = BinaryReader::default();
|
||||
if let Some(exe) = setup(
|
||||
reader,
|
||||
None,
|
||||
click_setup || args.contains(&"--silent-install".to_owned()),
|
||||
) {
|
||||
if click_setup {
|
||||
args = vec!["--install".to_owned()]
|
||||
}
|
||||
execute(exe, args);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ pub type NotifyMessageBox = fn(String, String, String, String) -> dyn Future<Out
|
||||
pub const CLIPBOARD_NAME: &'static str = "clipboard";
|
||||
pub const CLIPBOARD_INTERVAL: u64 = 333;
|
||||
|
||||
// the executable name of the portable version
|
||||
// the executable name of the portable version
|
||||
pub const PORTABLE_APPNAME_RUNTIME_ENV_KEY: &str = "RUSTDESK_APPNAME";
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
@ -564,7 +564,7 @@ pub fn is_ip(id: &str) -> bool {
|
||||
}
|
||||
|
||||
pub fn is_setup(name: &str) -> bool {
|
||||
name.to_lowercase().ends_with("install.exe") || name.to_lowercase().ends_with("安装.exe")
|
||||
name.to_lowercase().ends_with("install.exe")
|
||||
}
|
||||
|
||||
pub fn get_custom_rendezvous_server(custom: String) -> String {
|
||||
|
@ -1,5 +1,3 @@
|
||||
use std::env::Args;
|
||||
|
||||
use hbb_common::log;
|
||||
|
||||
// shared by flutter and sciter main function
|
||||
@ -10,14 +8,14 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
let mut args = Vec::new();
|
||||
let mut flutter_args = Vec::new();
|
||||
let mut i = 0;
|
||||
let mut is_setup = false;
|
||||
let mut _is_elevate = false;
|
||||
let mut _is_run_as_system = false;
|
||||
let mut _is_flutter_connect = false;
|
||||
let mut arg_exe = Default::default();
|
||||
for arg in std::env::args() {
|
||||
// to-do: how to pass to flutter?
|
||||
if i == 0 && crate::common::is_setup(&arg) {
|
||||
is_setup = true;
|
||||
if i == 0 {
|
||||
arg_exe = arg;
|
||||
} else if i > 0 {
|
||||
#[cfg(feature = "flutter")]
|
||||
if arg == "--connect" {
|
||||
@ -33,21 +31,14 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
if args.contains(&"--install".to_string()) {
|
||||
is_setup = true;
|
||||
}
|
||||
#[cfg(feature = "flutter")]
|
||||
if _is_flutter_connect {
|
||||
return core_main_invoke_new_connection(std::env::args());
|
||||
}
|
||||
if args.contains(&"--install".to_string()) {
|
||||
is_setup = true;
|
||||
}
|
||||
if is_setup {
|
||||
if args.is_empty() {
|
||||
args.push("--install".to_owned());
|
||||
flutter_args.push("--install".to_string());
|
||||
}
|
||||
let click_setup = cfg!(windows) && args.is_empty() && crate::common::is_setup(&arg_exe);
|
||||
if click_setup {
|
||||
args.push("--install".to_owned());
|
||||
flutter_args.push("--install".to_string());
|
||||
}
|
||||
if args.contains(&"--noinstall".to_string()) {
|
||||
args.clear();
|
||||
@ -233,7 +224,7 @@ fn import_config(path: &str) {
|
||||
/// [Note]
|
||||
/// this is for invoke new connection from dbus.
|
||||
#[cfg(feature = "flutter")]
|
||||
fn core_main_invoke_new_connection(mut args: Args) -> Option<Vec<String>> {
|
||||
fn core_main_invoke_new_connection(mut args: std::env::Args) -> Option<Vec<String>> {
|
||||
args.position(|element| {
|
||||
return element == "--connect";
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user