diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/dotup.rs | 15 | ||||
| -rw-r--r-- | src/main.rs | 9 |
2 files changed, 17 insertions, 7 deletions
diff --git a/src/dotup.rs b/src/dotup.rs index a7cccbe..296b182 100644 --- a/src/dotup.rs +++ b/src/dotup.rs | |||
| @@ -287,11 +287,18 @@ impl Dotup { | |||
| 287 | Ok(()) | 287 | Ok(()) |
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | pub fn status(&self) { | 290 | pub fn status(&self, paths: impl Iterator<Item = impl AsRef<Path>>) { |
| 291 | let status_result: anyhow::Result<()> = try { | 291 | let status_result: anyhow::Result<()> = try { |
| 292 | let canonical_dir = utils::current_working_directory(); | 292 | // canonicalize and remove paths whose parent we already have |
| 293 | let item = self.status_path_to_item(&canonical_dir)?; | 293 | let paths = paths.map(utils::weakly_canonical).collect::<HashSet<_>>(); |
| 294 | self.status_print_item(item, 0)?; | 294 | let paths = paths |
| 295 | .iter() | ||
| 296 | .filter(|p| !paths.iter().any(|x| p.starts_with(x) && p != &x)); | ||
| 297 | |||
| 298 | for path in paths { | ||
| 299 | let item = self.status_path_to_item(path)?; | ||
| 300 | self.status_print_item(item, 0)?; | ||
| 301 | } | ||
| 295 | }; | 302 | }; |
| 296 | if let Err(e) = status_result { | 303 | if let Err(e) = status_result { |
| 297 | println!("error while displaying status : {e}"); | 304 | println!("error while displaying status : {e}"); |
diff --git a/src/main.rs b/src/main.rs index 132b418..acd0e38 100644 --- a/src/main.rs +++ b/src/main.rs | |||
| @@ -214,10 +214,13 @@ fn command_mv(global_flags: Flags, args: MvArgs) -> anyhow::Result<()> { | |||
| 214 | 214 | ||
| 215 | /// Shows information about links | 215 | /// Shows information about links |
| 216 | #[derive(Parser, Debug)] | 216 | #[derive(Parser, Debug)] |
| 217 | struct StatusArgs {} | 217 | struct StatusArgs { |
| 218 | #[clap(default_value = ".")] | ||
| 219 | paths: Vec<PathBuf>, | ||
| 220 | } | ||
| 218 | 221 | ||
| 219 | fn command_status(global_flags: Flags, _args: StatusArgs) -> anyhow::Result<()> { | 222 | fn command_status(global_flags: Flags, args: StatusArgs) -> anyhow::Result<()> { |
| 220 | let dotup = utils::read_dotup(&global_flags)?; | 223 | let dotup = utils::read_dotup(&global_flags)?; |
| 221 | dotup.status(); | 224 | dotup.status(args.paths.into_iter()); |
| 222 | Ok(()) | 225 | Ok(()) |
| 223 | } | 226 | } |
