Skip to content

Commit

Permalink
Update and fix #152
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninjani committed Dec 26, 2023
1 parent f8be055 commit 87d2bb5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 29 deletions.
40 changes: 20 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,58 +17,58 @@ exclude = [

[dependencies]
# Argument parsing
clap = { version = "4.2.4", features = ["derive"] }
clap_complete = "4.2.1"
clap = { version = "4.4.11", features = ["derive"] }
clap_complete = "4.4.4"

# Configuration management
confy = "0.5.1"
directories-next = "1.0.2"

# Error management
eyre = "0.6.8"
eyre = "0.6.11"
color-eyre = { version = "0.6.2", default-features = false }
thiserror = "1.0.40"
thiserror = "1.0.52"

# Database related
sled = "0.34.7"
bincode = "1.3.3"

# Serializing
serde = "1.0.160"
serde_json = "1.0.96"
serde_derive = "1.0.160"
serde_yaml = "0.9.21"
serde = "1.0.193"
serde_json = "1.0.108"
serde_derive = "1.0.193"
serde_yaml = "0.9.29"

# Parsing and manipulating dates
chrono = { version = "0.4.24", features = ["serde"] }
chrono = { version = "0.4.31", features = ["serde"] }
chrono-english = "0.1.7"

# Taking user input and showing progress
dialoguer = {version = "0.11.0", features = ["completion", "history", "fuzzy-select"]}
indicatif = "0.17.3"
dialoguer = { version = "0.11.0", features = ["completion", "history", "fuzzy-select"] }
indicatif = "0.17.7"

# Fuzzy search
skim = "0.10.4"

# Terminal syntax highlighting
syntect = { version = "5.0.0", default-features = false, features = ["default-fancy"] }
syntect = { version = "5.1.0", default-features = false, features = ["default-fancy"] }
hex = "0.4.3"
grep-cli = "0.1.7"
termcolor = "1.2.0"
grep-cli = "0.1.10"
termcolor = "1.4.0"

# Sync to Gist/GitLab
ureq = { version = "2.6.2", features = ["json"] }
ureq = { version = "2.9.1", features = ["json"] }
strum = "0.25.0"
strum_macros = "0.25.3"

# pattern filter and filling shell script variables
regex = "1.8.1"
regex = "1.10.2"

[dev-dependencies]
assert_cmd = "2.0.11"
predicates = "3.0.3"
tempfile = "3.5.0"
expectrl = "0.7.0"
assert_cmd = "2.0.12"
predicates = "3.0.4"
tempfile = "3.8.1"
expectrl = "0.7.1"

[target.'cfg(target_os = "macos")'.dev-dependencies]
clipboard = "0.5.0"
Expand Down
7 changes: 5 additions & 2 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ pub enum LostTheWay {
#[error("ThemeError: {theme:?}")]
ThemeError { theme: String },
/// Thrown when trying to load a syntax which hasn't been added / doesn't exist
#[error("SyntaxError: {syntax:?}")]
SyntaxError { syntax: String },
#[error("SyntaxError: {message:?} {syntax_file:?}")]
SyntaxError {
syntax_file: String,
message: String,
},
/// Thrown when there's an error while trying to access system clipboard
#[error("ClipboardError: Couldn't copy to clipboard - {message}")]
ClipboardError { message: String },
Expand Down
8 changes: 5 additions & 3 deletions src/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,9 @@ impl CodeHighlight {
true,
None,
)
.map_err(|_e| LostTheWay::SyntaxError {
syntax: syntax_file.to_str().unwrap().into(),
.map_err(|e| LostTheWay::SyntaxError {
syntax_file: syntax_file.to_str().unwrap().into(),
message: e.to_string(),
})
.suggestion(format!(
"Couldn't load a syntax from {}, are you sure this is a valid .sublime-syntax file with a \'name\' key?",
Expand All @@ -319,7 +320,8 @@ impl CodeHighlight {
.file_name()
.and_then(std::ffi::OsStr::to_str)
.ok_or(LostTheWay::SyntaxError {
syntax: syntax_file.to_str().unwrap().into(),
syntax_file: syntax_file.to_str().unwrap().into(),
message: String::from("Filename is not valid Unicode"),
})
.suggestion("Something's fishy with the filename, valid Unicode?")?;
// Copy syntax file to syntect dir
Expand Down
8 changes: 4 additions & 4 deletions src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::collections::HashSet;
use std::io::Write;
use std::io::{IsTerminal, Write};
use std::process::{Command, Stdio};
use std::str;

Expand Down Expand Up @@ -140,13 +140,13 @@ pub fn parse_date(date_string: &str) -> color_eyre::Result<DateTime<Utc>> {
/// Some(date) => date
/// None => minimum possible date
pub fn date_start(from_date: Option<DateTime<Utc>>) -> DateTime<Utc> {
from_date.unwrap_or_else(|| DateTime::from_utc(NaiveDateTime::MIN, Utc))
from_date.unwrap_or_else(|| DateTime::from_naive_utc_and_offset(NaiveDateTime::MIN, Utc))
}

/// Some(date) => date
/// None => maximum possible date
pub fn date_end(to_date: Option<DateTime<Utc>>) -> DateTime<Utc> {
to_date.unwrap_or_else(|| DateTime::from_utc(NaiveDateTime::MAX, Utc))
to_date.unwrap_or_else(|| DateTime::from_naive_utc_and_offset(NaiveDateTime::MAX, Utc))
}

/// Gets input from external editor, optionally displays default text in editor
Expand Down Expand Up @@ -247,7 +247,7 @@ pub fn smart_print(
write!(
grep_cli::stdout(termcolor::ColorChoice::Auto),
"{}",
if !plain & (grep_cli::is_tty_stdout() | colorize) {
if !plain & (std::io::stdout().is_terminal() | colorize) {
highlight_strings(inputs, bg)
} else {
inputs
Expand Down

0 comments on commit 87d2bb5

Please sign in to comment.