Configuration File
The CLI stores configuration in a file named.defdrive_credentials in the directory where you run the CLI.
File Location
cli/ directory:
The credentials file is created in your current working directory, not in a fixed system location. If you run the CLI from different directories, separate configuration files will be created.
Stored Fields
The.defdrive_credentials file is a JSON file containing three fields:
Field Descriptions
| Field | Description | When Set |
|---|---|---|
url | The DefDrive server URL | After entering URL in step 0 |
token | Authentication token from login/signup | After successful authentication |
username | Your DefDrive username | After successful authentication |
Configuration Lifecycle
Initial Setup (No Config)
When you run the CLI for the first time:Existing Configuration Detected
When the CLI detects an existing.defdrive_credentials file with both URL and token, it displays a confirmation prompt:
Responding to the prompt
Responding to the prompt
Type
yes:- Continues with the existing configuration
- Skips authentication flow
- You can immediately use the CLI with stored credentials
no:- Resets the configuration (clears URL and token)
- Starts from the beginning
- Prompts for URL entry again
Partial Configuration
If.defdrive_credentials exists but only contains a URL (no token), the CLI:
- Loads the URL
- Skips the URL entry step
- Proceeds directly to the authentication menu
Configuration Updates
The configuration file is updated at specific points during CLI execution:URL Entry
saveConfig(url, "", "") is called when you enter the server URLSignup Success
saveConfig(url, token, username) is called after successful signupLogin Success
saveConfig(url, token, username) is called after successful loginFile Permissions
The credentials file is created with permissions0644:
- Owner: Read and write
- Group: Read only
- Others: Read only
Security ConsiderationThe Consider adding
.defdrive_credentials file contains your authentication token. For better security:.defdrive_credentials to your .gitignore if the CLI directory is part of a Git repository.Manual Configuration Management
View Current Configuration
Edit Configuration Manually
You can manually edit the JSON file:Reset Configuration
To start fresh, delete the credentials file:Backup Configuration
Multiple Environments
To manage multiple DefDrive instances, run the CLI from different directories:Configuration Source Code
The configuration logic is implemented in two functions incli/main.go:
Next Steps
Authentication
Learn about the signup and login flows
Introduction
Return to the CLI overview