Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,5 @@ In order to get the benefit of some features in cody you will need to copy the f
```
function cody_cd() {
eval $(cody open $@)
cd $(cat /tmp/cody_result)
}
```
26 changes: 23 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,39 @@ func runAdd(cmd *cobra.Command, args []string) error {
return nil
}

// ANSI color codes
const (
colorReset = "\033[0m"
colorGray = "\033[90m"
colorBlue = "\033[34m"
colorRed = "\033[31m"
)

func runPull(cmd *cobra.Command, args []string) error {
// filter := args[0]
urls, _ := collectAllCodyEntries()

for _, url := range urls {
dest := resolveCodyWorkspaceUrl(url)

if dest == "" {
fmt.Printf("%sSkipped (unsupported URL format): %s%s\n", colorGray, url, colorReset)
continue
}

// Check if .git directory exists (fast local check)
gitDir := filepath.Join(dest, ".git")
if info, err := os.Stat(gitDir); err == nil && info.IsDir() {
fmt.Printf("%sSkipped (already exists): %s%s\n", colorGray, url, colorReset)
continue
}

fmt.Printf("%sCloning: %s%s\n", colorBlue, url, colorReset)
if _, _, err := executeShellCommand("git", "clone", url, dest); err != nil {
fmt.Printf("Clone failed: %s\n", url)
fmt.Printf("%sClone failed: %s%s\n", colorRed, url, colorReset)
} else {
fmt.Println("Clone success: ", url, " to ", dest)
fmt.Printf("%sClone success: %s to %s%s\n", colorBlue, url, dest, colorReset)
}

}

return nil
Expand Down