summaryrefslogtreecommitdiffstats
path: root/src/print.rs
diff options
context:
space:
mode:
authorMatan Kushner <hello@matchai.me>2019-04-19 16:57:14 -0400
committerGitHub <noreply@github.com>2019-04-19 16:57:14 -0400
commit022e0002e40d9286677ae59e751b4b873dce6e95 (patch)
tree3769e569da5bbdeeb1c9c9759806deea5e1608f6 /src/print.rs
parent6d7485cf5017d05596db85ce49bc979ee3319057 (diff)
Use "context" to contain run details (#14)
* Create "context" to contain run details * Use context in tests and benchmarks
Diffstat (limited to 'src/print.rs')
-rw-r--r--src/print.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/print.rs b/src/print.rs
index c86083126..e2a371cb4 100644
--- a/src/print.rs
+++ b/src/print.rs
@@ -1,14 +1,12 @@
use clap::ArgMatches;
-use std::env;
use std::io::{self, Write};
+use crate::context::Context;
use crate::modules;
pub fn prompt(args: ArgMatches) {
- let default_prompt = vec!["directory", "nodejs", "line_break", "character"];
-
- // TODO: Currently gets the physical directory. Get the logical directory.
- let current_path = env::current_dir().expect("Unable to identify current directory.");
+ let prompt_order = vec!["directory", "nodejs", "line_break", "character"];
+ let context = Context::new(args);
// TODO:
// - List files in directory
@@ -20,9 +18,9 @@ pub fn prompt(args: ArgMatches) {
// Write a new line before the prompt
writeln!(handle).unwrap();
- default_prompt
+ prompt_order
.iter()
- .map(|module| modules::handle(module, &current_path, &args)) // Compute segments
+ .map(|module| modules::handle(module, &context)) // Compute segments
.flatten() // Remove segments set to `None`
.enumerate() // Turn segment into tuple with index
.map(|(index, segment)| segment.output_index(index)) // Generate string outputs