Skip to content

Conversation

@devin-ai-integration
Copy link

feat(cli): add --link flag to link configs without installs (issue #29)

Summary

This PR implements a new --link CLI flag that enables "link-only" operations as requested in issue #29. When used, the flag creates or updates symlinks for configuration files without running install commands, exporting/importing defaults, or persisting state changes.

Key Features:

  • Link-only execution: Only processes link sections from components, skipping install commands
  • Postlink hook support: Runs postlink hooks when present and linking succeeds
  • Profile & fuzzy search support: Works with the same profile selection and fuzzy search as regular runs
  • No state persistence: Intentionally bypasses profile saving and component state updates
  • Progress & verbose modes: Supports both --verbose and quiet (progress) execution modes

Files Changed:

  • cmd/dot/main.go: Added CLI flag, execution path, and state persistence guard
  • internal/component/component.go: Added LinkComponents and LinkComponentsWithProgress methods
  • cmd/dot/main_test.go & internal/component/component_test.go: Added test coverage
  • README.md: Updated with usage examples and behavior description

Review & Testing Checklist for Human

  • End-to-end testing: Run dot --link, dot --link [profile], and dot --link [fuzzy] to verify basic functionality works as expected
  • State isolation: Verify that link-only operations don't modify ~/.dot/state.json or persist profile changes (key behavioral difference)
  • Postlink hook execution: Test components with postlink hooks to ensure they run correctly and handle failures appropriately
  • Error handling: Test edge cases like components with no links, missing files, permission errors, and failed postlink hooks
  • CLI integration: Verify the flag works correctly with other flags like --dry-run, --verbose, and doesn't conflict with existing operations

Recommended Test Plan:

  1. Create a test component with both install and link sections plus a postlink hook
  2. Run dot --link [component] and verify only linking occurs (no installs, no state changes)
  3. Test with existing components like neovim to ensure expected output: ✔︎ *.cli.neovim linked

Diagram

%%{ init : { "theme" : "default" }}%%
graph TD
    CLI["cmd/dot/main.go<br/>CLI Entry Point"]:::major-edit
    ComponentMgr["internal/component/component.go<br/>Component Manager"]:::major-edit
    CLITest["cmd/dot/main_test.go<br/>CLI Flag Tests"]:::minor-edit
    ComponentTest["internal/component/component_test.go<br/>Link Component Tests"]:::minor-edit
    README["README.md<br/>Documentation"]:::minor-edit
    
    LinkMgr["internal/link/link.go<br/>Link Manager"]:::context
    StateMgr["internal/state/state.go<br/>State Manager"]:::context
    ExecMgr["internal/exec/exec.go<br/>Exec Manager"]:::context

    CLI --> ComponentMgr
    ComponentMgr --> LinkMgr
    ComponentMgr --> StateMgr
    ComponentMgr --> ExecMgr
    
    CLI -.-> CLITest
    ComponentMgr -.-> ComponentTest

    subgraph Legend
        L1[Major Edit]:::major-edit
        L2[Minor Edit]:::minor-edit  
        L3[Context/No Edit]:::context
    end

    classDef major-edit fill:#90EE90
    classDef minor-edit fill:#87CEEB  
    classDef context fill:#FFFFFF
Loading

Notes

  • Link to Devin run: https://app.devin.ai/sessions/4e6e13fa143142f898eecabb545ace40
  • Requested by: @pablopunk
  • Testing limitation: Unable to run tests locally due to go not being available on the development VM - relying on CI for validation
  • Behavioral design choice: Link-only mode intentionally skips state persistence to avoid side effects, but still runs postlink hooks which may have their own side effects
  • CLI complexity: The main execution path now has multiple conditional branches that should be carefully tested to ensure correct behavior in all scenarios

Implements link-only operation that symlinks configs and runs postlink hooks without installs/defaults/state persistence. Adds tests and docs.

Co-Authored-By: Pablo P Varela <pablo@pablopunk.com>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

…mode under Advanced Usage

Co-Authored-By: Pablo P Varela <pablo@pablopunk.com>
@devin-ai-integration
Copy link
Author

Closing due to inactivity for more than 7 days. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant