Knowing where to find things in the repo can be difficult. This document aims to help you find your way.
The cmd directory contains the source code for the CLI. The CLI is built using the cobra framework.
The CLI is split into several files:
- cmd/root.go contains the root command that is executed when
r2
is run - cmd/configure.go contains the
configure
command - cmd/cp.go contains the
cp
command - cmd/ls.go contains the
ls
command - cmd/mb.go contains the
mb
command - cmd/mv.go contains the
mv
command - cmd/presign.go contains the
presign
command - cmd/rb.go contains the
rb
command - cmd/rm.go contains the
rm
command - cmd/sync.go contains the
sync
command
The pkg directory contains the source code for the R2 package — the library enabling the CLI to communicate with R2.
- pkg/client.go contains all R2 client-level operations (e.g. configuration, bucket creation, etc.)
- pkg/bucket.go contains all bucket-level operations (e.g. listing objects, fetching objects, etc.)
- pkg/helpers.go contains miscellaneous helper functions used throughout the CLI
The workflows directory contains the GitHub Actions workflows used for this repo.
- .github/workflow/assembly.yml
- Bumps the version of the CLI in the install script to fetch the latest release
- .github/workflow/release.yml
- Builds and deploys the CLI to GitHub Releases
The assets directory contains the assets used for the repo.
- assets/bucket.svg is the R2 bucket icon used in the README
The install script is used to install the latest release of the CLI.
Thanks to Alex Kladov for his blog post on the importance of having an ARCHITECTURE.md file.