From 3e7149f880ffd5799d0bb9471649c4abb681679d Mon Sep 17 00:00:00 2001 From: Michael Pfaff Date: Fri, 10 Jun 2022 13:05:12 -0400 Subject: [PATCH] Simplify shortcut args --- src/install.rs | 13 ++----------- src/main.rs | 8 ++++---- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/install.rs b/src/install.rs index a4c0813..30bcb0a 100644 --- a/src/install.rs +++ b/src/install.rs @@ -194,18 +194,9 @@ impl<'a> Step<'a> { } ShortcutTarget::Executable { file: exec_file, args } => { use std::fmt::Write; - let mut args_str = String::new(); - let mut args = args.into_iter(); - if let Some(arg) = args.next() { - // TODO: quote properly - write!(args_str, "{:?}", arg).unwrap(); - } - for arg in args { - write!(args_str, " {:?}", arg).unwrap(); - } tokio::process::Command::new("powershell") .arg("-Command") - .arg(format!(r#"$shell = New-Object -ComObject WScript.Shell; $shortcut = $shell.CreateShortcut({file:?}); $shortcut.TargetPath = {exec_file:?}; $shortcut.Arguments = {args_str:?}; $shortcut.Save()"#)) + .arg(format!(r#"$shell = New-Object -ComObject WScript.Shell; $shortcut = $shell.CreateShortcut({file:?}); $shortcut.TargetPath = {exec_file:?}; $shortcut.Arguments = {args:?}; $shortcut.Save()"#)) .stdout(std::process::Stdio::inherit()) .stderr(std::process::Stdio::inherit()) .status() @@ -249,7 +240,7 @@ pub enum ShortcutTarget<'a> { file: Cow<'a, Path>, /// Arguments to the executable. - args: &'a [&'a str], + args: &'a str, }, /// A file or folder shortcut. Please use [`Self::Executable`] for shortcuts to binaries. diff --git a/src/main.rs b/src/main.rs index b89b500..739b54c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -65,7 +65,7 @@ async fn main() -> Result<()> { target: ShortcutTarget::Executable { file: nppp_dir.join("notepad++.exe").into(), - args: &[], + args: "", }, file: desktop_path().join("Notepad++.lnk").into(), }, @@ -88,7 +88,7 @@ async fn main() -> Result<()> { target: ShortcutTarget::Executable { file: epp_dir.join("Explorer++.exe").into(), - args: &[], + args: "", }, file: desktop_path().join("Explorer++.lnk").into(), }, @@ -105,7 +105,7 @@ async fn main() -> Result<()> { target: ShortcutTarget::Executable { file: minecraft_dir.join("Minecraft.exe").into(), - args: &[], + args: "", }, file: desktop_path().join("Minecraft.lnk").into(), }, @@ -126,7 +126,7 @@ async fn main() -> Result<()> { target: ShortcutTarget::Executable { file: Path::new("C:\\WINDOWS\\system32\\cmd.exe").into(), - args: &["/C", "powershell"], + args: "/C powershell", }, file: desktop_path().join("PowerShell.lnk").into(), }],