feat(cmd): add 'list' command to display managed files

Implements a new 'list' command that shows all files and directories managed by lnk, improving visibility and user experience.

fixes #4
This commit is contained in:
Yar Kravtsov
2025-05-26 05:57:45 +03:00
parent 69c1038f3e
commit 4a275ce4ca
6 changed files with 195 additions and 0 deletions

View File

@@ -428,6 +428,22 @@ func (l *Lnk) Pull() ([]string, error) {
return restored, nil
}
// List returns the list of files and directories currently managed by lnk
func (l *Lnk) List() ([]string, error) {
// Check if repository is initialized
if !l.git.IsGitRepository() {
return nil, fmt.Errorf("❌ Lnk repository not initialized\n 💡 Run \033[1mlnk init\033[0m first")
}
// Get managed items from .lnk file
managedItems, err := l.getManagedItems()
if err != nil {
return nil, fmt.Errorf("failed to get managed items: %w", err)
}
return managedItems, nil
}
// RestoreSymlinks finds all managed items from .lnk file and ensures they have proper symlinks
func (l *Lnk) RestoreSymlinks() ([]string, error) {
var restored []string