Skip to content

feat: add Rust CLI implementation#1

Merged
nmccready merged 2 commits into
mainfrom
feat/rust-impl
Apr 23, 2026
Merged

feat: add Rust CLI implementation#1
nmccready merged 2 commits into
mainfrom
feat/rust-impl

Conversation

@nmccready
Copy link
Copy Markdown
Contributor

@nmccready nmccready commented Apr 23, 2026

Summary

  • Add Rust CLI (envcache) with full feature parity to the shell version
  • 4 modules: config, secrets, cache, resolve — matching shell script behavior exactly
  • 13 unit tests covering secrets parsing, cache lifecycle, permissions, and refresh triggers
  • Multiple output formats: --format export (shell eval), --format dotenv, --format json
  • CI updated: tests.yml runs shell (bats) and Rust (fmt + clippy + test) in parallel
  • rust-release.yml workflow for cross-compiling binaries (linux/macOS, amd64/arm64) and uploading to GitHub Releases on tag

Usage (Rust binary)

# Resolve and cache (outputs export statements for eval)
eval "$(envcache)"

# Force refresh
eval "$(envcache --force)"

# Custom paths
envcache --secrets-file ./my-secrets --ttl 3600

# JSON output
envcache --format json

Architecture

src/
├── main.rs      — CLI (clap), output formatting
├── config.rs    — Config struct, defaults
├── secrets.rs   — Parse secrets file, hash for change detection
├── cache.rs     — Read/write cache + meta, freshness checks
└── resolve.rs   — Call `op read`, post-processors

Test plan

  • cargo fmt --check passes
  • cargo clippy -- -D warnings passes (zero warnings)
  • cargo test — 13/13 pass
  • npm run lint — shellcheck clean
  • npm test — 10/10 bats tests pass
  • CI runs both shell and Rust test suites in parallel

🤖 Generated with Claude Code

nmccready and others added 2 commits April 22, 2026 22:11
- Cargo.toml with clap, serde, chrono, anyhow
- 4 modules: config, secrets, cache, resolve
- Feature parity with shell version: TTL, first-login-of-day, force, secrets-file-change detection
- 13 unit tests (secrets parsing, cache read/write, permissions, refresh logic)
- Output formats: export (shell eval), dotenv, JSON
- CI: tests.yml runs both shell (bats) and Rust (fmt + clippy + test) in parallel
- rust-release.yml: cross-compile for linux/macOS amd64/arm64, upload to GitHub Releases
- Cargo.lock committed (binary project)
- Release profile: LTO, strip, size-optimized

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…vention)

- Create src/lib.rs to expose modules as a library crate alongside the binary
- Move #[cfg(test)] modules from cache.rs, secrets.rs, resolve.rs into tests/
- Make resolve::apply_post_processor pub for integration test access
- Update main.rs to import from the library crate instead of local modules
- Add [lib] section and exclude = ["tests/"] to Cargo.toml

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nmccready nmccready merged commit 2e62d3a into main Apr 23, 2026
6 checks passed
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