mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-24 14:36:42 +02:00
Merge pull request #310 from kdheepak/use-semver-version-comparison
Use semver version comparison
This commit is contained in:
commit
2ea45abf44
3 changed files with 36 additions and 19 deletions
35
Cargo.lock
generated
35
Cargo.lock
generated
|
@ -871,6 +871,12 @@ dependencies = [
|
|||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c64630dcdd71f1a64c435f54885086a0de5d6a12d104d69b165fb7d5286d677"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.4.4"
|
||||
|
@ -925,6 +931,17 @@ dependencies = [
|
|||
"memoffset",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ffd9d26838a953b4af82cbeb9f1592c6798916983959be223a7124e992742c1"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"minimal-lexical",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ntapi"
|
||||
version = "0.3.6"
|
||||
|
@ -1412,7 +1429,7 @@ dependencies = [
|
|||
"unicode-truncate",
|
||||
"unicode-width",
|
||||
"uuid",
|
||||
"version-compare",
|
||||
"versions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1525,18 +1542,22 @@ version = "0.8.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||
|
||||
[[package]]
|
||||
name = "version-compare"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe88247b92c1df6b6de80ddc290f3976dbdf2f5f5d3fd049a9fb598c6dd5ca73"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
|
||||
|
||||
[[package]]
|
||||
name = "versions"
|
||||
version = "3.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5cd9a7a22c45daf5aeb6bea3dff4ecbb8eb43e492582d467b18ce2979b512cbe"
|
||||
dependencies = [
|
||||
"itertools",
|
||||
"nom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "waker-fn"
|
||||
version = "1.1.0"
|
||||
|
|
|
@ -43,7 +43,7 @@ unicode-segmentation = "1.8.0"
|
|||
unicode-truncate = "0.2.0"
|
||||
unicode-width = "0.1.8"
|
||||
uuid = { version = "0.8.2", features = ["serde", "v4"] }
|
||||
version-compare = "0.1.0"
|
||||
versions = "3"
|
||||
|
||||
[package.metadata.rpm]
|
||||
package = "taskwarrior-tui"
|
||||
|
|
18
src/app.rs
18
src/app.rs
|
@ -78,12 +78,13 @@ use std::borrow::Borrow;
|
|||
use std::time::Instant;
|
||||
use task_hookrs::project::Project;
|
||||
|
||||
use version_compare::{Cmp, Version};
|
||||
use versions::Versioning;
|
||||
|
||||
const MAX_LINE: usize = 4096;
|
||||
|
||||
lazy_static! {
|
||||
static ref START_TIME: Instant = Instant::now();
|
||||
static ref LATEST_TASKWARRIOR_VERSION: Versioning = Versioning::new("2.6.0").unwrap();
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -205,7 +206,7 @@ pub struct TaskwarriorTui {
|
|||
pub report: String,
|
||||
pub projects: ProjectsState,
|
||||
pub contexts: ContextsState,
|
||||
pub task_version: String,
|
||||
pub task_version: Versioning,
|
||||
}
|
||||
|
||||
impl TaskwarriorTui {
|
||||
|
@ -239,11 +240,8 @@ impl TaskwarriorTui {
|
|||
.output()
|
||||
.context("Unable to run `task --version`")
|
||||
.unwrap();
|
||||
let task_version = String::from_utf8_lossy(&output.stdout).to_string();
|
||||
|
||||
if Version::from(&task_version).is_none() {
|
||||
return Err(anyhow!("Unable to parse `task --version`.\nGot {}", task_version));
|
||||
}
|
||||
let task_version = Versioning::new(String::from_utf8_lossy(&output.stdout).trim()).unwrap();
|
||||
|
||||
let (w, h) = crossterm::terminal::size()?;
|
||||
|
||||
|
@ -1586,15 +1584,13 @@ impl TaskwarriorTui {
|
|||
task.arg("rc.json.array=on");
|
||||
task.arg("rc.confirmation=off");
|
||||
|
||||
if Version::from(&self.task_version).unwrap() >= Version::from("2.6.0").unwrap() {
|
||||
if self.task_version >= *LATEST_TASKWARRIOR_VERSION {
|
||||
task.arg(format!("'{}'", self.filter.as_str().trim()));
|
||||
} else {
|
||||
task.arg(self.filter.as_str().trim());
|
||||
}
|
||||
|
||||
if !self.current_context_filter.is_empty()
|
||||
&& Version::from(&self.task_version).unwrap() >= Version::from("2.6.0").unwrap()
|
||||
{
|
||||
if !self.current_context_filter.is_empty() && self.task_version >= *LATEST_TASKWARRIOR_VERSION {
|
||||
task.arg(format!("'{}'", self.current_context_filter.trim()));
|
||||
} else if !self.current_context_filter.is_empty() {
|
||||
task.arg(format!("'\\({}\\)'", self.current_context_filter));
|
||||
|
@ -1602,7 +1598,7 @@ impl TaskwarriorTui {
|
|||
|
||||
task.arg("export");
|
||||
|
||||
if Version::from(&self.task_version).unwrap() >= Version::from("2.6.0").unwrap() {
|
||||
if self.task_version >= *LATEST_TASKWARRIOR_VERSION {
|
||||
task.arg(&self.report);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue