about summary refs log tree commit diff stats
path: root/pkgs/by-name/lf/lf-make-map/src/mapping/map_tree/lf_mapping.rs
blob: ba485dc2de37723d63928019a720a41371b057f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use std::path::PathBuf;

use crate::mapping::MapKey;

use super::MappingTree;

impl MappingTree {
    pub fn to_lf_mappings(self, home_path: PathBuf) -> String {
        let mut raw = self
            .iter(true)
            .map(|(key, value)| {
                format!(
                    "map g{} cd \"{}\"\n",
                    MapKey::display(&key),
                    home_path.join(&value).display()
                )
            })
            .collect::<Vec<String>>();

        raw.sort();

        raw.into_iter().collect()
    }
}