$ show SuperCuber/dotter
Dotter is a dotfile manager and templater written in Rust. It manages symbolic links and Handlebars-based templates for configuration files, supporting conditional deployment based on variables, packages, and host-specific configurations. The architecture is a single CLI binary with subcommands for deploy, undeploy, init, watch, and shell completion generation. It reads TOML configuration files (global.toml, local.toml) that define packages, files, and variables, then merges them with optional includes and patches. The deployment logic uses a trait-based Filesystem abstraction to support real operations and dry-run simulation, with platform-specific handling for Unix (sudo elevation) and Windows (symlink detection). The codebase demonstrates strong Rust practices: extensive use of traits for testability, mockall for unit testing, comprehensive error handling with anyhow, and a modular structure separating concerns (config, actions, filesystem, handlebars helpers, diff). It is actively maintained with recent commits, CI/CD pipelines, and a well-documented wiki.
The LLM identified 4 files worth highlighting for reuse:
Defines the Filesystem trait with methods for symlink/template comparison, file operations, and privilege elevation. Includes two implementations: RealFilesystem (with Unix sudo support and Windows symlink detection) and DryRunFilesystem (in-memory simulation for testing). The trait enables the entire deployment logic to be unit-tested without touching the real filesystem. This pattern is reusable for any CLI tool that needs to abstract filesystem operations for testability and cross-platform support.
Registers custom Handlebars helpers for dotfile templating: math (expression evaluation), include_template (embed other files), is_executable, command_success, and command_output. These helpers are self-contained and can be extracted and reused in any Handlebars-based project that needs dynamic condition evaluation or shell command integration. The registration logic is clean and the helpers are well-tested.
Provides diff generation and pretty-printing for template files. Implements hunkify_diff to group diff lines into hunks with context, and print_diff to display colored side-by-side diffs. This module is standalone (only depends on the `diff` crate and crossterm for styling) and can be reused in any application that needs to show file differences with context lines.
Handles loading and merging of TOML configuration files (global, local, includes, patches). Implements package dependency resolution (transitive dependencies), file target type discrimination (automatic, symbolic, template), directory expansion, and condition filtering. The merge logic with recursive variable extension and conflict detection is non-trivial and could be extracted for other multi-source configuration systems.