Skip to content

Commit 57fbe98

Browse files
committed
fix: support symlinks in decks directory
1 parent 08b013f commit 57fbe98

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

cmd/deck.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ var deckCmd = &cobra.Command{
1919

2020
// deckListCmd represents the deck list command
2121
var deckListCmd = &cobra.Command{
22-
Use: "list",
22+
Use: "ls",
2323
Short: "List available decks in your deck library",
2424
Run: func(cmd *cobra.Command, args []string) {
25-
libraryPath := config.GetDeckLibraryPath()
25+
libraryPath, err := filepath.EvalSymlinks(config.GetDeckLibraryPath())
26+
if err != nil {
27+
fmt.Printf("Error resolving symbolic link: %v\n", err)
28+
return
29+
}
2630

2731
// Check if deck library exists
2832
if _, err := os.Stat(libraryPath); os.IsNotExist(err) {
@@ -52,8 +56,17 @@ var deckListCmd = &cobra.Command{
5256
}
5357

5458
for _, entry := range entries {
55-
if entry.IsDir() {
56-
deckPath := filepath.Join(libraryPath, entry.Name())
59+
// Resolve the symbolic link or regular entry
60+
entryPath := filepath.Join(libraryPath, entry.Name())
61+
fileInfo, err := os.Stat(entryPath)
62+
if err != nil {
63+
fmt.Printf("Error resolving entry %s: %v\n", entry.Name(), err)
64+
continue
65+
}
66+
67+
// Check if the resolved entry is a directory
68+
if fileInfo.IsDir() {
69+
deckPath := entryPath
5770
d, err := deck.LoadDeck(deckPath)
5871

5972
if err != nil {

0 commit comments

Comments
 (0)