CLI Development
The bucky CLI is a Rust binary that sets up workflows in target repos via the GitHub API. Source code is in cli/.
Prerequisites
Section titled “Prerequisites”- Rust toolchain (stable)
- GitHub CLI (
gh) installed and authenticated
Commands
Section titled “Commands”cd climake build # cargo build --release (binary: target/release/bucky)make test # cargo test (unit + integration)make lint # cargo clippy -- -D warningsmake fmt # cargo fmtmake fmt-check # cargo fmt --checkmake install # build + copy binary to /usr/local/bin/buckyRun a single test:
cd cli && cargo test <test_name>Module structure
Section titled “Module structure”| Module | File | Purpose |
|---|---|---|
main | src/main.rs | Entry point, error handling |
cli | src/cli.rs | Arg parsing (clap), workflow enum, repo format validation, git remote detection |
preset | src/preset.rs | Preset enum, config loading from embedded presets.json |
detect | src/detect.rs | Auto-detect project type (checks for go.mod, package.json) |
templates | src/templates.rs | Embedded workflow templates with __PRESET__ and @main → @v{major} substitution |
version | src/version.rs | Version constants from VERSION file via build.rs |
github | src/github.rs | GitHub API interactions via octocrab |
prompt | src/prompt.rs | Interactive preset selection via dialoguer |
pr_body | src/pr_body.rs | PR description generation |
labels | src/labels.rs | Label creation/management |
output | src/output.rs | Output formatting |
Key patterns
Section titled “Key patterns”- Error handling:
anyhow::Resultthroughout; errors bubble up tomain()which prints and exits with code 1 - Async: Single-threaded tokio runtime (
current_thread) for GitHub API calls - Testing: Unit tests inline in source files, integration tests in
cli/tests/integration.rsusingassert_cmdandpredicates - Auth: Relies on
ghCLI being installed and authenticated - Compile-time embedding:
presets.jsonis embedded viainclude_str!and parsed into aLazyLock<HashMap>static; workflow templates embedded similarly; version fromVERSIONfile viabuild.rs - Dry-run:
--dry-runflag previews all changes without writing to the remote