Merge branch 'main' into development

This commit is contained in:
Arne Beer 2022-11-21 17:07:36 +01:00
commit 0b20956bbc
No known key found for this signature in database
GPG key ID: CC9408F679023B65
7 changed files with 46 additions and 40 deletions

29
Cargo.lock generated
View file

@ -249,35 +249,33 @@ dependencies = [
[[package]]
name = "clap"
version = "3.2.23"
version = "4.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5"
checksum = "2148adefda54e14492fb9bddcc600b4344c5d1a3123bd666dcb939c6f0e0e57e"
dependencies = [
"atty",
"bitflags",
"clap_derive",
"clap_lex",
"indexmap",
"once_cell",
"strsim",
"termcolor",
"textwrap",
]
[[package]]
name = "clap_complete"
version = "3.2.5"
version = "4.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f7a2e0a962c45ce25afce14220bc24f9dade0a1787f185cecf96bfba7847cd8"
checksum = "96b0fba905b035a30d25c1b585bf1171690712fbb0ad3ac47214963aa4acc36c"
dependencies = [
"clap",
]
[[package]]
name = "clap_derive"
version = "3.2.18"
version = "4.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65"
checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014"
dependencies = [
"heck",
"proc-macro-error",
@ -288,9 +286,9 @@ dependencies = [
[[package]]
name = "clap_lex"
version = "0.2.4"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
dependencies = [
"os_str_bytes",
]
@ -989,6 +987,8 @@ dependencies = [
"bitflags",
"cfg-if",
"libc",
"memoffset",
"pin-utils",
]
[[package]]
@ -1282,9 +1282,11 @@ dependencies = [
"env_logger",
"handlebars",
"log",
"nix 0.25.0",
"pest",
"pest_derive",
"pretty_assertions",
"procfs",
"pueue-lib",
"rstest",
"serde",
@ -1298,6 +1300,7 @@ dependencies = [
"tempfile",
"test-log",
"tokio",
"whoami",
]
[[package]]
@ -1906,12 +1909,6 @@ dependencies = [
"syn",
]
[[package]]
name = "textwrap"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
[[package]]
name = "thiserror"
version = "1.0.37"

View file

@ -61,8 +61,8 @@ pueue-lib = { version = "0.21.0", path = "lib" }
anyhow = "1"
chrono-english = "0.1"
clap = { version = "3", features = ["derive", "cargo"] }
clap_complete = "3"
clap = { version = "4", features = ["derive", "cargo"] }
clap_complete = "4"
comfy-table = "6"
crossbeam-channel = "0.5"
crossterm = { version = "0.25", default-features = false }
@ -97,3 +97,9 @@ similar-asserts = "1"
# nextest run --no-capture`)
env_logger = "0.9.1"
test-log = "0.2.11"
# Test specific dev-dependencies
[target.'cfg(any(target_os = "linux", target_os = "freebsd"))'.dependencies]
nix = "0.25"
whoami = "1"
procfs = { version = "0.14", default-features = false }

View file

@ -3,7 +3,8 @@ use std::path::PathBuf;
use chrono::prelude::*;
use chrono::Duration;
use chrono_english::*;
use clap::{ArgEnum, Parser, ValueHint};
use clap::ArgAction;
use clap::{Parser, ValueEnum, ValueHint};
use pueue_lib::network::message::Signal;
@ -13,7 +14,7 @@ pub enum SubCommand {
#[clap(trailing_var_arg = true)]
Add {
/// The command to be added.
#[clap(required = true, multiple_values = true, value_hint = ValueHint::CommandWithArguments)]
#[clap(required = true, num_args(1..), value_hint = ValueHint::CommandWithArguments)]
command: Vec<String>,
/// Specify current working directory.
@ -35,7 +36,7 @@ pub enum SubCommand {
stashed: bool,
/// Prevents the task from being enqueued until <delay> elapses. See "enqueue" for accepted formats.
#[clap(name = "delay", short, long, conflicts_with = "immediate", parse(try_from_str=parse_delay_until))]
#[clap(name = "delay", short, long, conflicts_with = "immediate", value_parser = parse_delay_until)]
delay_until: Option<DateTime<Local>>,
/// Assign the task to a group. Groups kind of act as separate queues.
@ -46,7 +47,7 @@ pub enum SubCommand {
/// Start the task once all specified tasks have successfully finished.
/// As soon as one of the dependencies fails, this task will fail as well.
#[clap(name = "after", short, long, multiple_values(true))]
#[clap(name = "after", short, long, num_args(1..))]
dependencies: Vec<usize>,
/// Add some information for yourself.
@ -111,7 +112,7 @@ pub enum SubCommand {
task_ids: Vec<usize>,
/// Delay enqueuing these tasks until <delay> elapses. See DELAY FORMAT below.
#[clap(name = "delay", short, long, parse(try_from_str=parse_delay_until))]
#[clap(name = "delay", short, long, value_parser = parse_delay_until)]
delay_until: Option<DateTime<Local>>,
},
@ -154,7 +155,7 @@ pub enum SubCommand {
/// Like `--all-failed`, but only restart tasks failed tasks of a specific group.
/// The group will be set to running and its paused tasks will be resumed.
#[clap(short = 'g', long, conflicts_with = "all-failed")]
#[clap(short = 'g', long, conflicts_with = "all_failed")]
failed_in_group: Option<String>,
/// Immediately start the tasks, no matter how many open slots there are.
@ -395,7 +396,7 @@ pub enum SubCommand {
/// By default, adjusts the amount of the default group.
Parallel {
/// The amount of allowed parallel tasks.
#[clap(validator=min_one)]
#[clap(value_parser = min_one)]
parallel_tasks: Option<usize>,
/// Set the amount for a specific group.
@ -407,7 +408,7 @@ pub enum SubCommand {
/// This can be ignored during normal operations.
Completions {
/// The target shell.
#[clap(arg_enum)]
#[clap(value_enum)]
shell: Shell,
/// The output directory to which the file should be written.
#[clap(value_hint = ValueHint::DirPath)]
@ -422,7 +423,7 @@ pub enum GroupCommand {
name: String,
/// Set the amount of parallel tasks this group can have.
#[clap(short, long, validator = min_one)]
#[clap(short, long, value_parser = min_one)]
parallel: Option<usize>,
},
@ -431,14 +432,14 @@ pub enum GroupCommand {
Remove { name: String },
}
#[derive(Parser, ArgEnum, Debug, Clone, PartialEq, Eq)]
#[derive(Parser, ValueEnum, Debug, Clone, PartialEq, Eq)]
pub enum ColorChoice {
Auto,
Never,
Always,
}
#[derive(Parser, ArgEnum, Debug, Clone, PartialEq, Eq)]
#[derive(Parser, ValueEnum, Debug, Clone, PartialEq, Eq)]
pub enum Shell {
Bash,
Elvish,
@ -456,11 +457,11 @@ pub enum Shell {
)]
pub struct CliArguments {
/// Verbose mode (-v, -vv, -vvv)
#[clap(short, long, parse(from_occurrences))]
#[clap(short, long, action = ArgAction::Count)]
pub verbose: u8,
/// Colorize the output; auto enables color output when connected to a tty.
#[clap(long, arg_enum, default_value = "auto")]
#[clap(long, value_enum, default_value = "auto")]
pub color: ColorChoice,
/// Path to a specific pueue config file to use.
@ -492,13 +493,13 @@ fn parse_delay_until(src: &str) -> Result<DateTime<Local>, String> {
}
/// Validator function. The input string has to be parsable as int and bigger than 0
fn min_one(value: &str) -> Result<(), String> {
fn min_one(value: &str) -> Result<usize, String> {
match value.parse::<usize>() {
Ok(value) => {
if value < 1 {
return Err("You must provide a value that's bigger than 0".into());
}
Ok(())
Ok(value)
}
Err(_) => Err("Failed to parse integer".into()),
}

View file

@ -103,8 +103,8 @@ impl<'a> TableBuilder<'a> {
}
}
/// Take a list of given [pest] rules from our [crate::apply_select] logic.
/// set the column visibility based on these rules.
/// Take a list of given [pest] rules from our `crate::query::column_selection::apply` logic.
/// Set the column visibility based on these rules.
pub fn set_visibility_by_rules(&mut self, rules: &[Rule]) {
// Don't change anything, if there're no rules
if rules.is_empty() {

View file

@ -1,7 +1,7 @@
use std::path::PathBuf;
use anyhow::{bail, Context, Result};
use clap::{IntoApp, Parser};
use clap::{CommandFactory, Parser};
use clap_complete::{generate_to, shells};
use log::warn;
use simplelog::{Config, ConfigBuilder, LevelFilter, SimpleLogger};

View file

@ -1,6 +1,6 @@
use std::path::PathBuf;
use clap::{Parser, ValueHint};
use clap::{ArgAction, Parser, ValueHint};
#[derive(Parser, Debug)]
#[clap(
@ -11,7 +11,7 @@ use clap::{Parser, ValueHint};
)]
pub struct CliArguments {
/// Verbose mode (-v, -vv, -vvv)
#[clap(short, long, parse(from_occurrences))]
#[clap(short, long, action = ArgAction::Count)]
pub verbose: u8,
/// If this flag is set, the daemon will start and fork itself into the background.

View file

@ -66,8 +66,10 @@ async fn restart_and_edit_task_path_and_command() -> Result<()> {
let shared = &daemon.settings.shared;
// Create a task and wait for it to finish.
assert_success(add_task(shared, "ls", false).await?);
wait_for_task_condition(shared, 0, |task| task.is_done()).await?;
assert_success(add_task(shared, "ls", false).await.unwrap());
wait_for_task_condition(shared, 0, |task| task.is_done())
.await
.unwrap();
// Set the editor to a command which replaces the temporary file's content.
let mut envs = HashMap::new();