Skip to main content
The DefDrive CLI is a Go application located in the cli/ directory of the DefDrive repository. This guide covers how to run and build the CLI.

Prerequisites

Before running the CLI, ensure you have:
1

Go Installed

Install Go 1.16 or later from golang.orgVerify your installation:
go version
2

DefDrive Repository

Clone or download the DefDrive repository containing the CLI source code
3

Dependencies

The CLI uses Bubble Tea for the TUI. Dependencies are managed via Go modules and will be automatically downloaded when you run the CLI.

Running the CLI

Option 1: Run Directly with Go

The simplest way to run the CLI is using go run:
go run cli/main.go
This command automatically downloads dependencies, compiles, and executes the CLI in one step.

Option 2: Build a Binary

For repeated use or distribution, build a standalone binary:
1

Navigate to CLI directory

cd cli
2

Build the binary

go build -o defdrive-cli main.go
3

Run the binary

./defdrive-cli

Option 3: Install Globally

Install the CLI to your $GOPATH/bin for system-wide access:
cd cli
go install
Then run from anywhere:
main  # Runs the installed binary
For a better command name, consider renaming the package or using go build with the -o flag to create a binary named defdrive.

Verifying Installation

After running the CLI with any method above, you should see the interactive prompt:
Enter the URL where DefDrive is hosted:
|

Press Enter to continue or q to quit.
If you see this prompt, the CLI is running correctly!

Dependencies

The CLI relies on the following Go packages:
  • github.com/charmbracelet/bubbletea - TUI framework for building the interactive interface
  • encoding/json - JSON encoding/decoding for API requests and config storage
  • net/http - HTTP client for API communication
  • io/ioutil - File I/O operations for credential storage
  • os - Operating system interface
  • strings - String manipulation utilities
  • fmt - Formatted I/O
All dependencies are automatically managed by Go modules. The go.mod and go.sum files track exact versions.

Troubleshooting

Ensure you’re running the command from the correct directory. The CLI should be run from either:
  • The repository root: go run cli/main.go
  • The cli directory: cd cli && go run main.go
If you’re behind a proxy or firewall, configure Go’s proxy settings:
export GOPROXY=https://proxy.golang.org,direct
Or disable module verification temporarily:
export GOSUMDB=off
If macOS blocks the binary due to security settings:
chmod +x defdrive-cli
xattr -d com.apple.quarantine defdrive-cli

Next Steps

Configuration

Learn how the CLI stores and manages credentials

Authentication

Understand the signup and login flows

Build docs developers (and LLMs) love