Development Guide: CLI
Component: cliLanguage: Go
Getting Started
Prerequisites
- Go 1.24+
- Access to a running Coder deployment (for API testing)
Build
To build the CLI from source:
bash
cd cli
go mod download
go build -o sptx ./cmdRunning Locally
You can run the CLI directly without building the binary:
bash
go run ./cmd/sptx helpTesting
Run the comprehensive test suite:
bash
go test -v ./...Project Structure
/cmd: Command definitions. Adding a new command? Start here./pkg: Reusable libraries./internal: Private implementation logic (config, helpers).
Common Tasks
- Adding a Command: Create a new file in
cmd/, define the Cobra command, and add it toroot.go. - Updating Dependencies: Run
go get <package>andgo mod tidy.