Skip to content

Commit

Permalink
Merge pull request #2319 from dathere/switch-back-to-simple_home_dir_…
Browse files Browse the repository at this point in the history
…from_simple-expand-tilde

Switch back to simple home dir from simple expand tilde
  • Loading branch information
jqnatividad authored Dec 2, 2024
2 parents 9afd32b + dbc0aba commit 3d1fd44
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 18 deletions.
15 changes: 3 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/fetchpost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/geocode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
1 change: 0 additions & 1 deletion src/cmd/luau.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
19 changes: 19 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Path>) -> Option<PathBuf> {
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,
Expand Down

0 comments on commit 3d1fd44

Please sign in to comment.