Skip to content

Commit

Permalink
🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
volllly committed Sep 11, 2022
1 parent 33d387d commit 07e57d2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use figment::{
value::{Dict, Map, Value},
Error, Metadata, Profile, Provider,
};
use itertools::Itertools;
use somok::Somok;

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

impl Dots {
fn add_root(&self) -> Self {
Self {
dots: self.dots.iter().map(|d| if d.starts_with('/') { d.to_string() } else { format!("/{d}") }).collect_vec(),
}
}
}

#[derive(Debug, Args, Bake, Clone)]
#[cfg_attr(test, derive(Dummy, PartialEq, Eq))]
#[baked(name = "Link")]
pub struct LinkRaw {
#[clap(flatten)]
#[baked(type = "Vec<String>", map = "self.dots.dots")]
#[baked(type = "Vec<String>", map_fn(bake = "|l| l.dots.add_root().dots"))]
pub(crate) dots: Dots,

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

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

#[clap(long, short)]
Expand Down

0 comments on commit 07e57d2

Please sign in to comment.