better-cp

Crates.iobetter-cp
lib.rsbetter-cp
version0.2.0
created_at2026-01-01 08:20:51.034121+00
updated_at2026-01-01 08:20:51.034121+00
descriptionModern replacement for cp/mv with progress reporting, safety guarantees, resumable transfers, and intelligent optimizations
homepage
repositoryhttps://github.com/nom-nom-hub/BetterDefaultCPMV
max_upload_size
id2015887
size179,429
Teck (Nom-nom-hub)

documentation

README

BetterDefaultCPMV

A modern replacement for cp and mv commands with progress reporting, safety guarantees, resumable transfers, and intelligent optimizations.

Features (MVP Phase 1 - Complete ✅)

  • Progress Bar + ETA: Real-time transfer speed, percentage complete, and time remaining
  • Safe Overwrite Behavior: Interactive prompts before overwriting with file details
  • Checksum Verification: SHA-256 verification after transfer
  • Resume Support: Continue interrupted copies from where they stopped
  • Atomic Operations: Use temporary files to prevent partial-overwrite exposure
  • Directory Recursion: Copy nested directories with proper structure preservation
  • Dry-Run Preview: Show what would be copied without making changes
  • Error Messages with Recovery Tips: Each error includes actionable guidance
  • JSON Output: Machine-readable structured output for scripting
  • Output Control: Quiet, normal, and verbose modes
  • Comprehensive Testing: 26 tests (13 unit + 13 integration) with 50%+ coverage

Installation

From Source

git clone <repo>
cd better-cp
cargo build --release
./target/release/better-cp --version

Binaries

Releases available at: https://github.com/betterdefaultcpmv/better-cp/releases

Quick Start

Basic Copy with Progress

better-cp large_file.iso backup/

Shows real-time progress:

Copying: large_file.iso → backup/
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 73% 
3.2 GB / 4.4 GB | 285 MB/s | ⏱ 4m 15s remaining

Resume Interrupted Transfer

better-cp --resume source/large.iso /backup/
# Copy interrupted? Just run again:
better-cp --resume source/large.iso /backup/
# Continues from where it left off!

Overwrite Modes

# Prompt before overwriting (default)
better-cp --overwrite=prompt source.txt dest.txt

# Never overwrite
better-cp --overwrite=never source.txt dest.txt

# Always overwrite without asking
better-cp --overwrite=always source.txt dest.txt

# Smart: only overwrite if source is newer
better-cp --overwrite=smart source.txt dest.txt

Dry Run

# Preview what would happen without copying
better-cp --dry-run source.txt destination.txt
# Output:
# 📋 Dry Run Preview (File)
#   Source: source.txt (1.5 GB)
#   Target: destination.txt (already exists)
#   Action: overwrite
# ✓ No files were modified (--dry-run)

Directory Copy

# Copy entire directory tree recursively
better-cp source_dir/ backup/source_dir/
# Copies: nested directories, all files, preserves structure

JSON Output

# Machine-readable output for scripting
better-cp --json large_file.iso backup/ | jq '.summary'
# Output:
# {
#   "bytes_transferred": 1650000000,
#   "files_copied": 1,
#   "duration_secs": 5.8,
#   "speed_mbps": 285.0,
#   "verified": true
# }

Error Messages with Recovery Tips

$ better-cp missing.txt backup/
# Output:
# ❌ Source not found: missing.txt
# Tip: Check that the source file/directory exists and the path is correct.

$ better-cp large.iso /readonly/
# Output:
# ❌ Permission denied: /readonly/
# Tip: Try running with elevated privileges (sudo on Linux/macOS).

$ better-cp file.zip /disk/ --verify=full
# Output:
# ❌ Checksum mismatch!
# Expected: abc123def456...
# Actual:   xyz789abc123...
# Tip: This indicates file corruption during transfer.
# Try copying again with --resume flag or check disk integrity.

Output Control

# Minimal output
better-cp --quiet large_file.iso backup/

# Detailed per-file output
better-cp --verbose source/ backup/

# Normal output (default)
better-cp source.txt backup/

Command Line Reference

Copy Command

better-cp [OPTIONS] SOURCE [SOURCE...] DESTINATION

Options

Flag Default Description
--overwrite=MODE prompt Overwrite behavior: never|prompt|always|smart
--resume auto Resume interrupted transfers
--no-resume - Disable resume
--verify=MODE fast Verification: none|fast|full
--no-verify - Skip checksums
--atomic true Use atomic operations
--parallel=N auto Number of parallel threads
--buffer=SIZE 64M Internal buffer size
--dry-run false Show what would happen
-v, --verbose false Detailed per-file output
-q, --quiet false Minimal output
--json false JSON output format
--log=FILE - Write operation log

Move Command

better-mv [OPTIONS] SOURCE [SOURCE...] DESTINATION

(Currently in development)

Configuration

Configuration file: ~/.config/better-cp/config.toml (Linux/macOS) or %APPDATA%\better-cp\config.toml (Windows)

Example config:

[defaults]
overwrite = "prompt"
resume = true
verify = "fast"
parallel = 4
sparse = true
reflink = "auto"

[behavior]
follow_symlinks = false
preserve_times = true
preserve_permissions = true
atomic = true

[performance]
buffer_size = "64M"
chunk_size = "100M"
resume_threshold = "100M"

[ui]
color = true
progress_style = "bars"
show_per_file = false

Architecture

Core Components

  • CLI Parser: Argument parsing and validation (using clap)
  • Transfer Engine: High-performance chunked copy with resume support
  • Progress Reporter: Real-time ETA and speed metrics
  • Verification: SHA-256 checksum validation
  • Resume Manager: State tracking for interrupted transfers
  • Configuration: Config file loading and defaults

Transfer Strategy

  1. Single Large File (>1GB): Chunked sequential copy with progress
  2. Many Small Files: Parallel threads for batch efficiency
  3. Directory: Recursive copy with atomic guarantees

Performance

Scenario Expected Improvement
Single 10GB file ~56% faster (with reflink: instant)
1000 small files ~4x faster (parallelization)
Interrupted transfer Resume saves re-copying already-transferred data

Development

Project Structure

src/
├── lib.rs          # Library exports
├── main.rs         # CLI entrypoint
├── cli.rs          # Argument parsing
├── copy.rs         # Core copy logic
├── error.rs        # Error types
├── progress.rs     # Progress tracking
├── resume.rs       # Resume state management
├── verify.rs       # Checksum verification
└── config.rs       # Configuration loading

Build

cargo build --release
cargo test
cargo clippy

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -am 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Roadmap

Phase 1: MVP ✅ COMPLETE

  • ✅ Core copy engine
  • ✅ Progress bar with ETA
  • ✅ Interactive overwrite safety with file details
  • ✅ Resumable interrupted transfers
  • ✅ SHA-256 checksum verification
  • ✅ Single and multi-file operations
  • ✅ Directory recursion with nesting support
  • ✅ Dry-run preview mode
  • ✅ Error messages with recovery suggestions
  • ✅ JSON output for scripting
  • ✅ Output control (quiet/verbose/normal)
  • ✅ Comprehensive test suite (26 tests, 50%+ coverage)

Phase 2: Performance & Features (Planned)

  • Parallel copy for directories
  • Reflink optimization (CoW on capable filesystems)
  • Sparse file support
  • better-mv full implementation
  • Config file validation
  • Shell completions

Phase 3: Cross-Platform (Planned)

  • macOS support (HFS+, APFS reflink)
  • Windows support (VSS, SMB, NTFS)
  • Linux optimization (ext4, Btrfs, XFS)

Phase 4: Polish (Planned)

  • Man pages
  • Extended documentation
  • Performance benchmarks
  • Community feedback integration

License

Apache 2.0 - See LICENSE file for details

Support

Commit count: 0

cargo fmt