diff --git a/lib/CHANGELOG.md b/lib/CHANGELOG.md index 1ee2f23d0..5d254f82d 100644 --- a/lib/CHANGELOG.md +++ b/lib/CHANGELOG.md @@ -8,6 +8,11 @@ The concept of SemVer is applied to the daemon/client API, but not the library A ## [0.21.0] - unreleased + +### Added + +- Added `Settings.shared.alias_file`, which can be used to specify the location of the `pueue_aliases.yml`. + ### Changed - The process handling code has been moved from the daemon to `pueue_lib`. See [#336](https://github.com/Nukesor/pueue/issues/336). diff --git a/lib/src/network/message.rs b/lib/src/network/message.rs index 3950309fc..e3e861746 100644 --- a/lib/src/network/message.rs +++ b/lib/src/network/message.rs @@ -128,6 +128,8 @@ pub struct StartMessage { pub children: bool, } +/// The messages used to restart tasks. +/// It's possible to update the command and paths when restarting tasks. #[derive(PartialEq, Eq, Clone, Debug, Deserialize, Serialize)] pub struct RestartMessage { pub tasks: Vec, @@ -138,7 +140,9 @@ pub struct RestartMessage { #[derive(PartialEq, Eq, Clone, Debug, Deserialize, Serialize)] pub struct TasksToRestart { pub task_id: usize, + /// The command that should be used when restarting the task. pub command: String, + /// The path that should be used when restarting the task. pub path: PathBuf, } diff --git a/lib/src/settings.rs b/lib/src/settings.rs index 4bc845fb3..0d01dbd17 100644 --- a/lib/src/settings.rs +++ b/lib/src/settings.rs @@ -19,17 +19,24 @@ pub struct Shared { /// The directory that is used for all of pueue's state. \ /// I.e. task logs, state dumps, etc. pub pueue_directory: Option, + /// Don't access this property directly, but rather use the getter with the same name. + /// It's only public to allow proper integration testing. + /// /// The location where runtime related files will be placed. /// Defaults to `pueue_directory` unless `$XDG_RUNTIME_DIR` is set. pub runtime_directory: Option, + /// Don't access this property directly, but rather use the getter with the same name. + /// It's only public to allow proper integration testing. + /// + /// The location of the alias file used by the daemon/client when working with + /// aliases. + pub alias_file: Option, + /// If this is set to true, unix sockets will be used. /// Otherwise we default to TCP+TLS #[cfg(not(target_os = "windows"))] #[serde(default = "default_true")] pub use_unix_socket: bool, - /// The path where the daemon's PID is located. - /// This is by default in `runtime_directory/pueue.pid`. - pub pid_path: Option, /// Don't access this property directly, but rather use the getter with the same name. /// It's only public to allow proper integration testing. /// @@ -43,6 +50,11 @@ pub struct Shared { /// The TCP port. #[serde(default = "default_port")] pub port: String, + + /// The path where the daemon's PID is located. + /// This is by default in `runtime_directory/pueue.pid`. + pub pid_path: Option, + /// Don't access this property directly, but rather use the getter with the same name. /// It's only public to allow proper integration testing. /// @@ -219,6 +231,18 @@ impl Shared { } } + /// The location of the alias file used by the daemon/client when working with + /// task aliases. + pub fn alias_file(&self) -> PathBuf { + if let Some(path) = &self.alias_file { + expand_home(path) + } else if let Some(config_dir) = dirs::config_dir() { + config_dir.join("pueue_aliases.yml") + } else { + PathBuf::from("pueue_aliases.yml") + } + } + /// The daemon's pid path can either be explicitly specified or it's simply placed in the /// current runtime directory. pub fn pid_path(&self) -> PathBuf { diff --git a/lib/tests/helper.rs b/lib/tests/helper.rs index 8a925e8a6..adb3361e7 100644 --- a/lib/tests/helper.rs +++ b/lib/tests/helper.rs @@ -15,6 +15,7 @@ pub fn get_shared_settings( let shared_settings = Shared { pueue_directory: Some(tempdir_path.to_path_buf()), runtime_directory: Some(tempdir_path.to_path_buf()), + alias_file: None, #[cfg(not(target_os = "windows"))] use_unix_socket, #[cfg(not(target_os = "windows"))]