Merge branch 'main' into development

This commit is contained in:
Arne Beer 2022-06-11 12:27:01 +02:00
commit 1569944c77
No known key found for this signature in database
GPG key ID: CC9408F679023B65
17 changed files with 112 additions and 211 deletions

View file

@ -4,6 +4,34 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2.0.4] - 2022-06-05
### Fixed
- Return the correct path from `pueue_lib::settings::configuration_directories()`,
when we get a path from `dirs::config_dir()` (was `/home/<user>/.config/pueue.yaml/`, is now again `/home/<user>/.config/pueue/`).
- Use the correct path to delete the PID file during shutdown.
## [2.0.3] - 2022-06-04
### Fixed
- Use the `dirs` crate for platform specific directory discovery. [#311](https://github.com/Nukesor/pueue/issues/311)
The previous trivial implementation was error prone in some edge-cases.
For instance, Pueue fell back to the shared directory, if the `$XDG_RUNTIME_DIR` couldn't be found.
This resulted in a reocurrence of [#302](https://github.com/Nukesor/pueue/issues/302) in non-XDG environments.
Furthermore, Pueue used the wrong directories for its configuration and cache on Apple and Windows platforms.
This is now fixed.
This change is a bit tricky:
* It's a fix on one hand (correct directories for Apple & Windows + fix for [#311](https://github.com/Nukesor/pueue/issues/311)).
* It's somewhat of a **breaking change** for Apple & Windows on the other hand?
I still decided to make this a patch release, as the next major release is still in the pipeline and needs a lot of work.
[#302](https://github.com/Nukesor/pueue/issues/302) will still show up in Apple/Windows environments, as there doesn't seem to be runtime directory equivalent for those platforms.
## [2.0.2] - 2022-03-22
### Added

134
Cargo.lock generated
View file

@ -205,9 +205,9 @@ dependencies = [
[[package]]
name = "clap"
version = "3.1.17"
version = "3.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47582c09be7c8b32c0ab3a6181825ababb713fde6fff20fc573a3870dd45c6a0"
checksum = "d2dbdf4bdacb33466e854ce889eee8dfd5729abf7ccd7664d0a2d60cd384440b"
dependencies = [
"atty",
"bitflags",
@ -231,11 +231,11 @@ dependencies = [
[[package]]
name = "clap_derive"
version = "3.1.7"
version = "3.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3aab4734e083b809aaf5794e14e756d1c798d2c69c7f7de7a09a2f5214993c1"
checksum = "25320346e922cffe59c0bbc5410c8d8784509efb321488971081313cb1e1a33c"
dependencies = [
"heck 0.4.0",
"heck",
"proc-macro-error",
"proc-macro2",
"quote",
@ -253,13 +253,13 @@ dependencies = [
[[package]]
name = "comfy-table"
version = "5.0.1"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b103d85ca6e209388771bfb7aa6b68a7aeec4afbf6f0a0264bfbf50360e5212e"
checksum = "121d8a5b0346092c18a4b2fd6f620d7a06f0eb7ac0a45860939a0884bc579c56"
dependencies = [
"crossterm",
"strum 0.23.0",
"strum_macros 0.23.1",
"strum",
"strum_macros",
"unicode-width",
]
@ -476,16 +476,16 @@ checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
[[package]]
name = "handlebars"
version = "4.2.2"
version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99d6a30320f094710245150395bc763ad23128d6a1ebbad7594dc4164b62c56b"
checksum = "d113a9853e5accd30f43003560b5563ffbb007e3f325e8b103fa0d0029c6e6df"
dependencies = [
"log",
"pest",
"pest_derive",
"quick-error",
"serde",
"serde_json",
"thiserror",
]
[[package]]
@ -494,15 +494,6 @@ version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
[[package]]
name = "heck"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "heck"
version = "0.4.0"
@ -526,9 +517,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "indexmap"
version = "1.8.1"
version = "1.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee"
checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a"
dependencies = [
"autocfg",
"hashbrown",
@ -554,9 +545,9 @@ dependencies = [
[[package]]
name = "itoa"
version = "1.0.1"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"
checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d"
[[package]]
name = "js-sys"
@ -575,9 +566,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.125"
version = "0.2.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b"
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
[[package]]
name = "linked-hash-map"
@ -627,9 +618,9 @@ dependencies = [
[[package]]
name = "miniz_oxide"
version = "0.5.1"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082"
checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc"
dependencies = [
"adler",
]
@ -707,9 +698,9 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.10.0"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225"
[[package]]
name = "opaque-debug"
@ -719,9 +710,9 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
[[package]]
name = "os_str_bytes"
version = "6.0.0"
version = "6.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa"
[[package]]
name = "output_vt100"
@ -893,11 +884,11 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.38"
version = "1.0.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9027b48e9d4c9175fa2218adf3557f91c1137021739951d4932f5f8268ac48aa"
checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
dependencies = [
"unicode-xid",
"unicode-ident",
]
[[package]]
@ -915,7 +906,7 @@ dependencies = [
[[package]]
name = "pueue"
version = "2.0.2"
version = "2.0.4"
dependencies = [
"anyhow",
"assert_cmd",
@ -949,7 +940,7 @@ dependencies = [
[[package]]
name = "pueue-lib"
version = "0.19.5"
version = "0.19.7"
dependencies = [
"anyhow",
"async-trait",
@ -972,8 +963,8 @@ dependencies = [
"serde_yaml",
"shellexpand",
"snap",
"strum 0.24.0",
"strum_macros 0.24.0",
"strum",
"strum_macros",
"tempdir",
"thiserror",
"tokio",
@ -981,12 +972,6 @@ dependencies = [
"whoami",
]
[[package]]
name = "quick-error"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
[[package]]
name = "quote"
version = "1.0.18"
@ -1164,9 +1149,9 @@ dependencies = [
[[package]]
name = "rustls"
version = "0.20.4"
version = "0.20.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fbfeb8d0ddb84706bc597a5574ab8912817c52a397f819e5b614e2265206921"
checksum = "5aab8ee6c7097ed6057f43c187a62418d0c05a4bd5f18b3571db50ee0f9ce033"
dependencies = [
"log",
"ring",
@ -1191,9 +1176,9 @@ checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f"
[[package]]
name = "ryu"
version = "1.0.9"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f"
checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695"
[[package]]
name = "scanlex"
@ -1302,9 +1287,9 @@ dependencies = [
[[package]]
name = "signal-hook"
version = "0.3.13"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "647c97df271007dcea485bb74ffdb57f2e683f1306c854f468a0c244badabf2d"
checksum = "a253b5e89e2698464fc26b545c9edceb338e18a89effeeecfea192c3025be29d"
dependencies = [
"libc",
"signal-hook-registry",
@ -1354,12 +1339,12 @@ checksum = "45456094d1983e2ee2a18fdfebce3189fa451699d0502cb8e3b49dba5ba41451"
[[package]]
name = "socket2"
version = "0.4.5"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca642ba17f8b2995138b1d7711829c92e98c0a25ea019de790f4f09279c4e296"
checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0"
dependencies = [
"libc",
"windows-sys",
"winapi",
]
[[package]]
@ -1374,38 +1359,19 @@ version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "strum"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cae14b91c7d11c9a851d3fbc80a963198998c2a64eec840477fa92d8ce9b70bb"
[[package]]
name = "strum"
version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e96acfc1b70604b8b2f1ffa4c57e59176c7dbb05d556c71ecd2f5498a1dee7f8"
[[package]]
name = "strum_macros"
version = "0.23.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bb0dc7ee9c15cea6199cde9a127fa16a4c5819af85395457ad72d68edc85a38"
dependencies = [
"heck 0.3.3",
"proc-macro2",
"quote",
"rustversion",
"syn",
]
[[package]]
name = "strum_macros"
version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6878079b17446e4d3eba6192bb0a2950d5b14f0ed8424b852310e5a94345d0ef"
dependencies = [
"heck 0.4.0",
"heck",
"proc-macro2",
"quote",
"rustversion",
@ -1414,13 +1380,13 @@ dependencies = [
[[package]]
name = "syn"
version = "1.0.92"
version = "1.0.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ff7c592601f11445996a06f8ad0c27f094a58857c2f89e97974ab9235b92c52"
checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
"unicode-ident",
]
[[package]]
@ -1579,10 +1545,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
[[package]]
name = "unicode-segmentation"
version = "1.9.0"
name = "unicode-ident"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99"
checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
[[package]]
name = "unicode-width"
@ -1590,12 +1556,6 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
[[package]]
name = "unicode-xid"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04"
[[package]]
name = "untrusted"
version = "0.7.1"

View file

@ -1,7 +1,7 @@
[package]
name = "pueue"
description = "A cli tool for managing long running shell commands."
version = "2.0.2"
version = "2.0.4"
authors = ["Arne Beer <contact@arne.beer>"]
homepage = "https://github.com/nukesor/pueue"
repository = "https://github.com/nukesor/pueue"
@ -33,7 +33,7 @@ name = "pueued"
path = "daemon/main.rs"
[dependencies]
pueue-lib = { version = "0.19.5", path = "lib" }
pueue-lib = { version = "0.19.7", path = "lib" }
anyhow = "1"
chrono = { version = "0.4", features = ["serde"] }
@ -53,7 +53,7 @@ simplelog = { version = "0.12", default-features = false }
clap = { version = "3", features = ["derive", "cargo"] }
clap_complete = "3"
crossterm = "0.23"
comfy-table = "5"
comfy-table = "6"
handlebars = "4"
ctrlc = { version = "3", features = ["termination"] }

View file

@ -198,6 +198,10 @@ There seems to be the need for some solution that satisfies all these points men
## Similar Projects
**GNU Parallel**
A robust and featureful parrallel processor with text-based joblog and n-retries. [GNU Parallel](https://www.gnu.org/software/parallel/parallel_tutorial.html) is able to scale to multi-host parallelization and has complex code to have deep integration across different tools and shells, as well as other advanced features. `Pueue` differentiates itself from GNU Parallel by focusing more on visibility across many different long running commands, and creating a central location for commands to be stored, rather than GNU Parallel's focus on chunking a specific task.
**nq**
A very lightweight job queue systems which require no setup, maintenance, supervision, or any long-running processes. \

View file

@ -186,7 +186,7 @@ fn print_task_info(task: &Task, colors: &Colors) {
}
// Set the padding of the left column to 0 align the keys to the right
let first_column = table.get_column_mut(0).unwrap();
let first_column = table.column_mut(0).unwrap();
first_column.set_cell_alignment(CellAlignment::Right);
first_column.set_padding((0, 0));

View file

@ -175,7 +175,7 @@ impl TaskHandler {
}
// Cleanup the pid file
if let Err(error) = cleanup_pid_file(&self.pueue_directory) {
if let Err(error) = cleanup_pid_file(&self.settings.shared.pid_path()) {
println!("Failed to cleanup pid during shutdown.");
println!("{error}");
}

View file

@ -1,7 +1,7 @@
[package]
name = "pueue-lib"
description = "The shared library to work with the Pueue client and daemon."
version = "0.19.5"
version = "0.19.7"
authors = ["Arne Beer <contact@arne.beer>"]
homepage = "https://github.com/nukesor/pueue"
repository = "https://github.com/nukesor/pueue"

View file

@ -4,15 +4,14 @@ use std::io::prelude::*;
use log::{info, warn};
use crate::error::Error;
use crate::platform::directories::get_config_directories;
use crate::{error::Error, settings::configuration_directories};
/// Return the contents of the alias file, if it exists and can be parsed. \
/// The file has to be located in `pueue_directory` and named `pueue_aliases.yml`.
pub fn get_aliases() -> Result<HashMap<String, String>, Error> {
// Go through all config directories and check for a alias file.
let mut alias_file_path = None;
for directory in get_config_directories() {
for directory in configuration_directories() {
let path = directory.join("pueue_aliases.yml");
if path.exists() {
alias_file_path = Some(path);

View file

@ -17,8 +17,6 @@ pub mod error;
/// Helper classes to read and write log files of Pueue's tasks.
pub mod log;
pub mod network;
/// Platform specific code, mainly used to get platform specific working directories.
mod platform;
/// This module contains all platform unspecific default values and helper functions for working
/// with our setting representation.
mod setting_defaults;

View file

@ -1,21 +0,0 @@
use std::path::PathBuf;
pub fn get_home_dir() -> PathBuf {
dirs::home_dir().unwrap_or_else(|| PathBuf::from("/"))
}
pub fn default_pueue_path() -> PathBuf {
get_home_dir().join(".local/share/pueue")
}
pub fn default_runtime_directory() -> Option<PathBuf> {
None
}
pub fn get_config_directories() -> Vec<PathBuf> {
vec![default_config_directory(), PathBuf::from(".")]
}
pub fn default_config_directory() -> PathBuf {
get_home_dir().join("Library/Preferences/pueue")
}

View file

@ -1 +0,0 @@
pub mod directories;

View file

@ -1,38 +0,0 @@
use std::path::PathBuf;
use crate::settings::expand_home;
fn get_home_dir() -> PathBuf {
dirs::home_dir().unwrap_or_else(|| PathBuf::from("/"))
}
pub fn default_pueue_path() -> PathBuf {
if let Ok(path) = std::env::var("XDG_DATA_HOME") {
expand_home(&PathBuf::from(path)).join("pueue")
} else {
get_home_dir().join(".local/share/pueue")
}
}
/// Try to find `XDG_RUNTIME_DIR` in the environment.
pub fn default_runtime_directory() -> Option<PathBuf> {
if let Ok(path) = std::env::var("XDG_RUNTIME_DIR") {
Some(expand_home(&PathBuf::from(path)))
} else {
None
}
}
pub fn get_config_directories() -> Vec<PathBuf> {
vec![default_config_directory(), PathBuf::from(".")]
}
/// Return the default config directory for pueue.
/// This follows the XDG specification and uses `XDG_CONFIG_HOME` if it's set.
pub fn default_config_directory() -> PathBuf {
if let Ok(path) = std::env::var("XDG_CONFIG_HOME") {
PathBuf::from(path).join("pueue")
} else {
get_home_dir().join(".config/pueue")
}
}

View file

@ -1 +0,0 @@
pub mod directories;

View file

@ -1,19 +0,0 @@
/// MacOs specific stuff
#[cfg(target_vendor = "apple")]
pub mod apple;
/// Linux specific stuff
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
pub mod linux;
/// Windows specific stuff
#[cfg(target_os = "windows")]
pub mod windows;
// The next block is platform specific directory functions
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
pub use self::linux::directories;
#[cfg(target_vendor = "apple")]
pub use self::apple::directories;
#[cfg(target_os = "windows")]
pub use self::windows::directories;

View file

@ -1,26 +0,0 @@
use std::path::PathBuf;
// Use local data directory since this data doesn't need to be synced.
pub fn data_local_dir() -> PathBuf {
dirs::data_local_dir().unwrap_or_else(|| PathBuf::from("\\"))
}
pub fn default_pueue_path() -> PathBuf {
data_local_dir().join("pueue")
}
pub fn default_runtime_directory() -> Option<PathBuf> {
None
}
pub fn default_config_directory() -> PathBuf {
data_local_dir().join("pueue")
}
pub fn get_config_directories() -> Vec<PathBuf> {
vec![
// Windows Terminal stores its config file in the "AppData/Local" directory.
default_config_directory(),
PathBuf::from("."),
]
}

View file

@ -1 +0,0 @@
pub mod directories;

View file

@ -8,7 +8,6 @@ use serde_derive::{Deserialize, Serialize};
use shellexpand::tilde;
use crate::error::Error;
use crate::platform::directories::*;
use crate::setting_defaults::*;
/// All settings which are used by both, the client and the daemon
@ -168,6 +167,16 @@ pub struct NestedSettings {
pub shared: Shared,
}
/// Get the default config directory.
/// If no config can be found, fallback to the current directory.
pub fn configuration_directories() -> Vec<PathBuf> {
if let Some(config_dir) = dirs::config_dir() {
vec![config_dir.join("pueue"), PathBuf::from(".")]
} else {
vec![PathBuf::from(".")]
}
}
/// Little helper which expands a given path's `~` characters to a fully qualified path.
pub fn expand_home(old_path: &Path) -> PathBuf {
PathBuf::from(tilde(&old_path.to_string_lossy()).into_owned())
@ -177,8 +186,10 @@ impl Shared {
pub fn pueue_directory(&self) -> PathBuf {
if let Some(path) = &self.pueue_directory {
expand_home(path)
} else if let Some(path) = dirs::data_local_dir() {
path.join("pueue")
} else {
default_pueue_path()
PathBuf::from("./pueue")
}
}
@ -189,10 +200,10 @@ impl Shared {
pub fn runtime_directory(&self) -> PathBuf {
if let Some(path) = &self.runtime_directory {
expand_home(path)
} else if let Some(path) = default_runtime_directory() {
} else if let Some(path) = dirs::runtime_dir() {
path
} else {
default_pueue_path()
self.pueue_directory()
}
}
@ -263,7 +274,9 @@ impl Settings {
};
info!("Parsing config files");
for directory in get_config_directories().into_iter() {
let config_dirs = configuration_directories();
for directory in config_dirs.into_iter() {
let path = directory.join("pueue.yml");
info!("Checking path: {path:?}");
@ -293,8 +306,14 @@ impl Settings {
pub fn save(&self, path: &Option<PathBuf>) -> Result<(), Error> {
let config_path = if let Some(path) = path {
path.clone()
} else if let Some(path) = dirs::config_dir() {
let path = path.join("pueue");
path.join("pueue.yml")
} else {
default_config_directory().join("pueue.yml")
return Err(Error::Generic(
"Failed to resolve default config directory. User home cannot be determined."
.into(),
));
};
let config_dir = config_path
.parent()