about summary refs log tree commit diff stats
path: root/sys/nixpkgs/pkgs/lf-make-map/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sys/nixpkgs/pkgs/lf-make-map/src/main.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/sys/nixpkgs/pkgs/lf-make-map/src/main.rs b/sys/nixpkgs/pkgs/lf-make-map/src/main.rs
index ccda1f14..aaf79b20 100644
--- a/sys/nixpkgs/pkgs/lf-make-map/src/main.rs
+++ b/sys/nixpkgs/pkgs/lf-make-map/src/main.rs
@@ -2,8 +2,8 @@ use std::path::{Path, PathBuf};
 
 use anyhow::{Context, Result};
 use clap::Parser;
-use cli::Args;
-use log::{debug, trace};
+use cli::{Args, Command};
+use log::trace;
 use mapping::map_tree::MappingTree;
 use walkdir::{DirEntry, WalkDir};
 
@@ -26,7 +26,12 @@ fn main() -> anyhow::Result<()> {
 
     let mut mappings = MappingTree::new();
 
-    for dir in args.relevant_directories {
+    let relevant_directories = match &args.command {
+        Command::Visualize { options } => &options.relevant_directories,
+        Command::Generate { options } => &options.relevant_directories,
+    };
+
+    for dir in relevant_directories {
         trace!("Processing '{}'..", dir.display());
         let path = strip_path(&dir, &args.home_name)?;
 
@@ -39,7 +44,7 @@ fn main() -> anyhow::Result<()> {
 
     let mut current_depth = 1;
     while current_depth != args.depth {
-        for (key, value) in mappings.iter() {
+        for (key, value) in mappings.iter(false) {
             trace!(
                 "Adding to child ('{}' -> '{}')",
                 MapKey::display(&key),
@@ -87,7 +92,10 @@ fn main() -> anyhow::Result<()> {
         current_depth += 1;
     }
 
-    println!("{}", mappings);
+    match args.command {
+        Command::Visualize { .. } => println!("{}", mappings),
+        Command::Generate { .. } => println!("{}", mappings.to_lf_mappings(args.home_name)),
+    }
 
     Ok(())
 }