From c8f7539fbffa60be24d3c3b6df50cd9ee7913f73 Mon Sep 17 00:00:00 2001 From: Petr Gadorek Date: Tue, 30 Jul 2024 12:46:05 +0200 Subject: [PATCH] added creating shortcut on windows desktop --- Cargo.lock | 116 ++++++++++++++++++++++++++++++++++++++++++++-- Cargo.toml | 2 +- locales/app.yml | 8 +++- src/wizard/mod.rs | 24 ++++++++-- 4 files changed, 140 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d9a7e4c..69fe049 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -680,6 +680,28 @@ dependencies = [ "windows-targets 0.52.5", ] +[[package]] +name = "chrono-tz" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93698b29de5e97ad0ae26447b344c482a7284c737d9ddc5f9e52b74a336671bb" +dependencies = [ + "chrono", + "chrono-tz-build", + "phf", +] + +[[package]] +name = "chrono-tz-build" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c088aee841df9c3041febbb73934cfc39708749bf96dc827e3359cd39ef11b1" +dependencies = [ + "parse-zoneinfo", + "phf", + "phf_codegen", +] + [[package]] name = "cipher" version = "0.4.4" @@ -1086,6 +1108,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c877555693c14d2f84191cfd3ad8582790fc52b5e2274b40b59cf5f5cea25c7" +[[package]] +name = "deunicode" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339544cc9e2c4dc3fc7149fd630c5f22263a4fdf18a98afd0075784968b5cf00" + [[package]] name = "dialoguer" version = "0.11.0" @@ -1532,6 +1560,17 @@ dependencies = [ "walkdir", ] +[[package]] +name = "globwalk" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf760ebf69878d9fd8f110c89703d90ce35095324d1f1edcb595c63945ee757" +dependencies = [ + "bitflags 2.5.0", + "ignore", + "walkdir", +] + [[package]] name = "h2" version = "0.4.5" @@ -1685,6 +1724,15 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +[[package]] +name = "humansize" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cb51c9a029ddc91b07a787f1d86b53ccfa49b0e86688c946ebe8d3555685dd7" +dependencies = [ + "libm", +] + [[package]] name = "humantime" version = "2.1.0" @@ -1805,7 +1853,7 @@ dependencies = [ [[package]] name = "idf-im-lib" version = "0.1.0" -source = "git+https://github.com/espressif/idf-im-lib.git?rev=9a7a3e4806b63ce9b1a49538772fbc9c5e00619a#9a7a3e4806b63ce9b1a49538772fbc9c5e00619a" +source = "git+https://github.com/espressif/idf-im-lib.git?rev=4e83b798add624f45479fd126e852ff8eaf952cd#4e83b798add624f45479fd126e852ff8eaf952cd" dependencies = [ "colored", "decompress", @@ -1821,6 +1869,7 @@ dependencies = [ "serde_json", "sha2", "sys-info", + "tera", "tokio", "winapi", "winreg 0.52.0", @@ -2793,6 +2842,15 @@ dependencies = [ "windows-targets 0.52.5", ] +[[package]] +name = "parse-zoneinfo" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f2a05b18d44e2957b88f96ba460715e295bc1d7510468a2f3d3b44535d26c24" +dependencies = [ + "regex", +] + [[package]] name = "password-hash" version = "0.4.2" @@ -3432,7 +3490,7 @@ version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dcd94370631e5658a0a23635f7f47e43d06a00ad948e0bb5de79b00d85b880c" dependencies = [ - "globwalk", + "globwalk 0.8.1", "once_cell", "regex", "rust-i18n-macro", @@ -3464,7 +3522,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "399801f4d955abf1c3ce3ce2215dc76bd40beb4ae39e3a84936b21a79ce2caa5" dependencies = [ "arc-swap", - "globwalk", + "globwalk 0.8.1", "lazy_static", "normpath", "once_cell", @@ -4219,6 +4277,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slug" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd94acec9c8da640005f8e135a39fc0372e74535e6b368b7a04b875f784c8c4" +dependencies = [ + "deunicode", + "wasm-bindgen", +] + [[package]] name = "smallvec" version = "1.13.2" @@ -4425,6 +4493,28 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "tera" +version = "1.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab9d851b45e865f178319da0abdbfe6acbc4328759ff18dafc3a41c16b4cd2ee" +dependencies = [ + "chrono", + "chrono-tz", + "globwalk 0.9.1", + "humansize", + "lazy_static", + "percent-encoding", + "pest", + "pest_derive", + "rand 0.8.5", + "regex", + "serde", + "serde_json", + "slug", + "unic-segment", +] + [[package]] name = "termios" version = "0.3.3" @@ -4841,6 +4931,15 @@ dependencies = [ "unic-ucd-normal", ] +[[package]] +name = "unic-segment" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ed5d26be57f84f176157270c112ef57b86debac9cd21daaabbe56db0f88f23" +dependencies = [ + "unic-ucd-segment", +] + [[package]] name = "unic-ucd-age" version = "0.9.0" @@ -4907,6 +5006,17 @@ dependencies = [ "unic-ucd-version", ] +[[package]] +name = "unic-ucd-segment" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2079c122a62205b421f499da10f3ee0f7697f012f55b675e002483c73ea34700" +dependencies = [ + "unic-char-property", + "unic-char-range", + "unic-ucd-version", +] + [[package]] name = "unic-ucd-version" version = "0.9.0" diff --git a/Cargo.toml b/Cargo.toml index 11ad171..9515da3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] tokio = {version = "1.37.0", features=["full"]} -idf-im-lib = { git = "https://github.com/espressif/idf-im-lib.git", rev="9a7a3e4806b63ce9b1a49538772fbc9c5e00619a" } +idf-im-lib = { git = "https://github.com/espressif/idf-im-lib.git", rev="4e83b798add624f45479fd126e852ff8eaf952cd" } clap = {version = "4.5", features = ["cargo", "derive", "color"]} crossterm = "0.27.0" dialoguer = { git = "https://github.com/Hahihula/dialoguer.git", branch = "folder-select", features = ["folder-select"] } diff --git a/locales/app.yml b/locales/app.yml index 09987ef..c89fe6d 100644 --- a/locales/app.yml +++ b/locales/app.yml @@ -172,4 +172,10 @@ wizard.after_install.config.saved: cn: 配置已保存成功到 config.toml wizard.after_install.config.save_failed: en: Configuration save failed - cn: 配置保存失败 \ No newline at end of file + cn: 配置保存失败 +wizard.after_install.desktop_shortcut.created: + en: Desktop shortcut created successfully + cn: 已创建 desktop 快捷方式 +wizard.after_install.desktop_shortcut.failed: + en: Failed to create desktop shortcut + cn: 创建 desktop 快捷方式失败 \ No newline at end of file diff --git a/src/wizard/mod.rs b/src/wizard/mod.rs index 7e56b67..ab7681b 100644 --- a/src/wizard/mod.rs +++ b/src/wizard/mod.rs @@ -754,14 +754,28 @@ pub async fn run_wizzard_run(mut config: Settings) -> Result<(), String> { let export_paths = get_tools_export_paths(tools, &target, tool_install_directory.to_str().unwrap()); - #[cfg(windows)] if std::env::consts::OS == "windows" { - for p in export_paths { - let _ = idf_im_lib::win_tools::add_to_win_path(&p); - } + // for p in export_paths { + // let _ = idf_im_lib::win_tools::add_to_win_path(&p); + // } println!("{}", t!("wizard.windows.succes_message")); + // Creating desktop shortcut + match idf_im_lib::create_desktop_shortcut( + instalation_path.to_str().unwrap(), + idf_path.to_str().unwrap(), + tool_install_directory.to_str().unwrap(), + ) { + Ok(_) => info!("{}", t!("wizard.after_install.desktop_shortcut.created")), + Err(err) => { + error!( + "{} {:?}", + t!("wizard.after_install.desktop_shortcut.failed"), + err.to_string() + ) + } + } } - #[cfg(not(windows))] + if std::env::consts::OS != "windows" { let exports = env_vars .into_iter()