diff --git a/Cargo.lock b/Cargo.lock index 89b4d5a0f..233c99b7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5398,7 +5398,7 @@ dependencies = [ "sha256", "simd-json", "simdutf8", - "simple-expand-tilde", + "simple-home-dir", "sled", "smallvec", "snap", @@ -6471,20 +6471,11 @@ version = "0.1.5" source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" -[[package]] -name = "simple-expand-tilde" -version = "0.4.4" -source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "d1c0c40a0159680f204592e46b3fcd6fe6dae02adad57e94534e1f642318b396" -dependencies = [ - "simple-home-dir", -] - [[package]] name = "simple-home-dir" -version = "0.4.4" +version = "0.4.5" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "2d80554cb5ec21f0163f142f4078427aaa5a93d40e87e9ad2b6b8392c26e20f8" +checksum = "d50f2938e12058068c9bb06ff39c57937befe678ebb8ab2eaf6c9b7559bbbd14" dependencies = [ "windows-sys 0.59.0", ] diff --git a/Cargo.toml b/Cargo.toml index 19dabd01c..fec26740a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -237,7 +237,7 @@ semver = "1" serde = { version = "1", features = ["derive"] } serde_json = { version = "1", features = ["preserve_order"] } serde_urlencoded = { version = "0.7", optional = true } -simple-expand-tilde = "0.4" +simple-home-dir = "0.4" sled = { version = "0.34", optional = true } smallvec = "1" snap = "1" diff --git a/src/cmd/fetch.rs b/src/cmd/fetch.rs index d92b87526..5e84aa733 100644 --- a/src/cmd/fetch.rs +++ b/src/cmd/fetch.rs @@ -260,8 +260,8 @@ use reqwest::{ }; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; -use simple_expand_tilde::expand_tilde; use url::Url; +use util::expand_tilde; use crate::{ config::{Config, Delimiter}, diff --git a/src/cmd/fetchpost.rs b/src/cmd/fetchpost.rs index 1a7977dd6..71e1fb587 100644 --- a/src/cmd/fetchpost.rs +++ b/src/cmd/fetchpost.rs @@ -273,8 +273,8 @@ use reqwest::{ }; use serde::Deserialize; use serde_json::{json, Value}; -use simple_expand_tilde::expand_tilde; use url::Url; +use util::expand_tilde; use crate::{ cmd::fetch::{ diff --git a/src/cmd/geocode.rs b/src/cmd/geocode.rs index 4b925ae18..8a8e2649c 100644 --- a/src/cmd/geocode.rs +++ b/src/cmd/geocode.rs @@ -386,9 +386,9 @@ use rayon::{ use regex::Regex; use serde::Deserialize; use serde_json::json; -use simple_expand_tilde::expand_tilde; use tempfile::tempdir; use url::Url; +use util::expand_tilde; use uuid::Uuid; use crate::{ diff --git a/src/cmd/luau.rs b/src/cmd/luau.rs index 8ddabc28b..e0dcba7b2 100644 --- a/src/cmd/luau.rs +++ b/src/cmd/luau.rs @@ -251,7 +251,6 @@ use log::{debug, info, log_enabled}; use mlua::{Lua, LuaSerdeExt, Value}; use serde::Deserialize; -// use simple_expand_tilde::expand_tilde; use crate::{ config::{Config, Delimiter, DEFAULT_WTR_BUFFER_CAPACITY}, lookup, util, CliError, CliResult, diff --git a/src/lookup.rs b/src/lookup.rs index dc939ad21..0a0763f6a 100644 --- a/src/lookup.rs +++ b/src/lookup.rs @@ -8,7 +8,7 @@ use std::{ use log::{debug, info}; use reqwest::blocking::Client; use serde_json::Value; -use simple_expand_tilde::expand_tilde; +use util::expand_tilde; use crate::{util, CliError}; diff --git a/src/util.rs b/src/util.rs index ff71b4fe0..48311e6d3 100644 --- a/src/util.rs +++ b/src/util.rs @@ -2255,6 +2255,25 @@ pub fn optimal_batch_size(rconfig: &Config, batch_size: usize, num_jobs: usize) } } +/// Expand the tilde (`~`) from within the provided path. +/// copied from /~https://github.com/splurf/simple-expand-tilde +/// as it was just a small wrapper around simple_home_dir +pub fn expand_tilde(path: impl AsRef) -> Option { + let p = path.as_ref(); + + let expanded = if p.starts_with("~") { + let mut base = simple_home_dir::home_dir()?; + + if !p.ends_with("~") { + base.extend(p.components().skip(1)); + } + base + } else { + p.to_path_buf() + }; + Some(expanded) +} + // comment out for now as this is still WIP // pub fn create_json_record( // no_headers: bool,