Skip to content

Commit 07e57d2

Browse files
committed
🐛
1 parent 33d387d commit 07e57d2

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/cli.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use figment::{
1010
value::{Dict, Map, Value},
1111
Error, Metadata, Profile, Provider,
1212
};
13+
use itertools::Itertools;
1314
use somok::Somok;
1415

1516
use crate::{config::LinkType, helpers, FILE_EXTENSIONS, PROJECT_DIRS};
@@ -63,12 +64,20 @@ pub struct Dots {
6364
pub(crate) dots: Vec<String>,
6465
}
6566

67+
impl Dots {
68+
fn add_root(&self) -> Self {
69+
Self {
70+
dots: self.dots.iter().map(|d| if d.starts_with('/') { d.to_string() } else { format!("/{d}") }).collect_vec(),
71+
}
72+
}
73+
}
74+
6675
#[derive(Debug, Args, Bake, Clone)]
6776
#[cfg_attr(test, derive(Dummy, PartialEq, Eq))]
6877
#[baked(name = "Link")]
6978
pub struct LinkRaw {
7079
#[clap(flatten)]
71-
#[baked(type = "Vec<String>", map = "self.dots.dots")]
80+
#[baked(type = "Vec<String>", map_fn(bake = "|l| l.dots.add_root().dots"))]
7281
pub(crate) dots: Dots,
7382

7483
#[clap(long, short)]
@@ -87,7 +96,7 @@ pub struct LinkRaw {
8796
#[allow(clippy::struct_excessive_bools)]
8897
pub struct InstallRaw {
8998
#[clap(flatten)]
90-
#[baked(type = "Vec<String>", map = "self.dots.dots")]
99+
#[baked(type = "Vec<String>", map_fn(bake = "|l| l.dots.add_root().dots"))]
91100
pub(crate) dots: Dots,
92101

93102
/// Continues installation when an error occurs during installation
@@ -112,7 +121,7 @@ pub struct InstallRaw {
112121
#[baked(name = "Sync")]
113122
pub struct SyncRaw {
114123
#[clap(flatten)]
115-
#[baked(type = "Vec<String>", map = "self.dots.dots")]
124+
#[baked(type = "Vec<String>", map_fn(bake = "|l| l.dots.add_root().dots"))]
116125
pub(crate) dots: Dots,
117126

118127
#[clap(long, short)]

0 commit comments

Comments
 (0)