diff options
author | Matan Kushner <hello@matchai.me> | 2019-04-19 16:57:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-19 16:57:14 -0400 |
commit | 022e0002e40d9286677ae59e751b4b873dce6e95 (patch) | |
tree | 3769e569da5bbdeeb1c9c9759806deea5e1608f6 /src/modules/directory.rs | |
parent | 6d7485cf5017d05596db85ce49bc979ee3319057 (diff) |
Use "context" to contain run details (#14)
* Create "context" to contain run details
* Use context in tests and benchmarks
Diffstat (limited to 'src/modules/directory.rs')
-rw-r--r-- | src/modules/directory.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/modules/directory.rs b/src/modules/directory.rs index 8048a3620..265b90a3c 100644 --- a/src/modules/directory.rs +++ b/src/modules/directory.rs @@ -1,10 +1,10 @@ -use super::Segment; use ansi_term::Color; -use clap::ArgMatches; -use dirs; use git2::Repository; use std::path::Path; +use super::Segment; +use crate::context::Context; + /// Creates a segment with the current directory /// /// Will perform path contraction and truncation. @@ -14,12 +14,13 @@ use std::path::Path; /// /// **Truncation** /// Paths will be limited in length to `3` path components by default. -pub fn segment(current_dir: &Path, _args: &ArgMatches) -> Option<Segment> { +pub fn segment(context: &Context) -> Option<Segment> { const HOME_SYMBOL: &str = "~"; const DIR_TRUNCATION_LENGTH: usize = 3; const SECTION_COLOR: Color = Color::Cyan; let mut segment = Segment::new("dir"); + let current_dir = &context.current_dir; let dir_string; if let Ok(repo) = git2::Repository::discover(current_dir) { |