From c5bc49884d00998850fd1142b007acc44a54a663 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Sun, 28 Jun 2020 00:21:28 +0530 Subject: [PATCH] Fix imports --- src/subcommand/add.rs | 10 +++++----- src/subcommand/import.rs | 8 ++++---- src/subcommand/init/shell/posix.rs | 6 +++--- src/subcommand/remove.rs | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/subcommand/add.rs b/src/subcommand/add.rs index 1b9537c..043af52 100644 --- a/src/subcommand/add.rs +++ b/src/subcommand/add.rs @@ -1,6 +1,6 @@ use crate::config; use crate::db::{Db, Dir, Rank}; -use crate::util::{canonicalize, get_current_time, get_db, path_to_str}; +use crate::util; use anyhow::{Context, Result}; use structopt::StructOpt; @@ -32,15 +32,15 @@ impl Add { fn add>(path: P) -> Result<()> { let path = path.as_ref(); - let path = canonicalize(&path)?; + let path = util::canonicalize(&path)?; if config::zo_exclude_dirs().contains(&path) { return Ok(()); } - let mut db = get_db()?; - let now = get_current_time()?; - let path = path_to_str(&path)?; + let mut db = util::get_db()?; + let now = util::get_current_time()?; + let path = util::path_to_str(&path)?; let maxage = config::zo_maxage()?; match db.dirs.iter_mut().find(|dir| dir.path == path) { diff --git a/src/subcommand/import.rs b/src/subcommand/import.rs index fd224dd..4bf782a 100644 --- a/src/subcommand/import.rs +++ b/src/subcommand/import.rs @@ -1,5 +1,5 @@ use crate::db::{Db, Dir}; -use crate::util::{canonicalize, get_db, path_to_str}; +use crate::util; use anyhow::{bail, Context, Result}; use structopt::StructOpt; @@ -26,7 +26,7 @@ impl Import { fn import>(path: P, merge: bool) -> Result<()> { let path = path.as_ref(); - let mut db = get_db()?; + let mut db = util::get_db()?; if !db.dirs.is_empty() && !merge { bail!( @@ -70,8 +70,8 @@ fn import_line(db: &mut Db, line: &str) -> Result<()> { .parse::() .with_context(|| format!("invalid rank: {}", rank_str))?; - let path = canonicalize(&path)?; - let path = path_to_str(&path)?; + let path = util::canonicalize(&path)?; + let path = util::path_to_str(&path)?; // If the path exists in the database, add the ranks and set the epoch to // the more recent of the parsed epoch and the already present epoch. diff --git a/src/subcommand/init/shell/posix.rs b/src/subcommand/init/shell/posix.rs index be0b227..fe31229 100644 --- a/src/subcommand/init/shell/posix.rs +++ b/src/subcommand/init/shell/posix.rs @@ -1,5 +1,5 @@ use super::{HookConfig, ShellConfig}; -use crate::util::path_to_str; +use crate::util; use anyhow::Result; use uuid::Uuid; @@ -80,10 +80,10 @@ esac fn hook_pwd() -> Result> { let mut tmp_path = std::env::temp_dir(); tmp_path.push("zoxide"); - let tmp_path_str = path_to_str(&tmp_path)?; + let tmp_path_str = util::path_to_str(&tmp_path)?; let pwd_path = tmp_path.join(format!("pwd-{}", Uuid::new_v4())); - let pwd_path_str = path_to_str(&pwd_path)?; + let pwd_path_str = util::path_to_str(&pwd_path)?; let hook_pwd = format!( r#" diff --git a/src/subcommand/remove.rs b/src/subcommand/remove.rs index 35dcbc2..bf99e2c 100644 --- a/src/subcommand/remove.rs +++ b/src/subcommand/remove.rs @@ -1,4 +1,4 @@ -use crate::util::{canonicalize, get_db, path_to_str}; +use crate::util; use anyhow::{bail, Result}; use structopt::StructOpt; @@ -17,7 +17,7 @@ impl Remove { } fn remove(path: &str) -> Result<()> { - let mut db = get_db()?; + let mut db = util::get_db()?; if let Some(idx) = db.dirs.iter().position(|dir| dir.path == path) { db.dirs.swap_remove(idx); @@ -25,8 +25,8 @@ fn remove(path: &str) -> Result<()> { return Ok(()); } - let path = canonicalize(&path)?; - let path = path_to_str(&path)?; + let path = util::canonicalize(&path)?; + let path = util::path_to_str(&path)?; if let Some(idx) = db.dirs.iter().position(|dir| dir.path == path) { db.dirs.swap_remove(idx);