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/character.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/character.rs')
-rw-r--r-- | src/modules/character.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/modules/character.rs b/src/modules/character.rs index 359ff61fb..f624e19f2 100644 --- a/src/modules/character.rs +++ b/src/modules/character.rs @@ -1,7 +1,7 @@ -use super::Segment; use ansi_term::Color; -use clap::ArgMatches; -use std::path::Path; + +use super::Segment; +use crate::context::Context; /// Creates a segment for the prompt character /// @@ -11,14 +11,15 @@ use std::path::Path; /// (green by default) /// - If the exit-code was anything else, the arrow will be formatted with /// `COLOR_FAILURE` (red by default) -pub fn segment(_current_dir: &Path, args: &ArgMatches) -> Option<Segment> { +pub fn segment(context: &Context) -> Option<Segment> { const PROMPT_CHAR: &str = "➜"; const COLOR_SUCCESS: Color = Color::Green; const COLOR_FAILURE: Color = Color::Red; let mut segment = Segment::new("char"); + let arguments = &context.arguments; - if args.value_of("status_code").unwrap() == "0" { + if arguments.value_of("status_code").unwrap() == "0" { segment.set_style(COLOR_SUCCESS); } else { segment.set_style(COLOR_FAILURE); |