Skip to content

Commit 94b147c

Browse files
authored
refactor: update windows registry and address some bugs (#22)
1 parent b5c700a commit 94b147c

File tree

5 files changed

+222
-300
lines changed

5 files changed

+222
-300
lines changed

Cargo.lock

Lines changed: 50 additions & 121 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ exclude = ["/test-exe"]
1414
thiserror = "2"
1515

1616
[target."cfg(not(target_os = \"windows\"))".dependencies]
17-
dirs = "5.0.1"
17+
dirs = "6"
1818

1919
[target.'cfg(windows)'.dependencies]
20-
windows-registry = "0.3.0"
21-
windows-result = "0.2.0"
20+
windows-registry = "0.5"
21+
windows-result = "0.3"

src/lib.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
//! let app_name = "the-app";
7979
//! let app_path = "C:\\path\\to\\the-app.exe";
8080
//! let args = &["--minimized"];
81-
//! let auto = AutoLaunch::new(app_name, app_path, args);
81+
//! let enable_mode = WindowsEnableMode::CurrentUser;
82+
//! let auto = AutoLaunch::new(app_name, app_path, args, enable_mode);
8283
//!
8384
//! // enable the auto launch
8485
//! auto.enable().is_ok();
@@ -182,7 +183,8 @@ mod windows;
182183
/// # let app_name = "the-app";
183184
/// # let app_path = "/path/to/the-app";
184185
/// # let args = &["--minimized"];
185-
/// AutoLaunch::new(app_name, app_path, args);
186+
/// # let enable_mode = WindowsEnableMode::CurrentUser;
187+
/// AutoLaunch::new(app_name, app_path, args, enable_mode);
186188
/// # }
187189
/// ```
188190
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -193,15 +195,15 @@ pub struct AutoLaunch {
193195
/// The application executable path (absolute path will be better)
194196
pub(crate) app_path: String,
195197

198+
/// Args passed to the binary on startup
199+
pub(crate) args: Vec<String>,
200+
196201
#[cfg(target_os = "macos")]
197202
/// Whether use Launch Agent for implement or use AppleScript
198203
pub(crate) use_launch_agent: bool,
199204

200205
#[cfg(windows)]
201206
pub(crate) enable_mode: WindowsEnableMode,
202-
203-
/// Args passed to the binary on startup
204-
pub(crate) args: Vec<String>,
205207
}
206208

207209
impl AutoLaunch {
@@ -340,9 +342,6 @@ impl AutoLaunchBuilder {
340342
///
341343
/// - `app_name` is none
342344
/// - `app_path` is none
343-
///
344-
/// ## Panics
345-
///
346345
/// - Unsupported target OS
347346
pub fn build(&self) -> Result<AutoLaunch> {
348347
let app_name = self.app_name.as_ref().ok_or(Error::AppNameNotSpecified)?;

0 commit comments

Comments
 (0)