zephyrfs-cli Public
ZephyrFS CLI
Command-line interface for ZephyrFS distributed P2P storage network.
Features
- =€ Easy Setup: Initialize and configure nodes with interactive prompts
- = Network Management: Join and manage P2P network connections
- =Á File Operations: Upload, download, and list files across the network
- =Ê Monitoring: Built-in metrics and status monitoring
- ¡ Performance: Benchmarking and performance analysis tools
- =' Configuration: YAML/TOML configuration file support
Installation
From Source
git clone https://github.com/ZephyrFS/zephyrfs-cli.git
cd zephyrfs-cli
cargo build --release
The compiled binary will be available at target/release/zephyrfs.
Using Cargo
cargo install zephyrfs-cli
Quick Start
1. Initialize a Node
# Interactive setup
zephyrfs init
# Non-interactive with options
zephyrfs init --name my-node --port 8080 --storage 50
2. Join a Network
zephyrfs join 192.168.1.100:8081
3. Upload Files
zephyrfs upload /path/to/file.txt
zephyrfs upload large-file.zip --verify
4. List Files
zephyrfs list
zephyrfs list --long --sort size
5. Download Files
zephyrfs download a1b2c3d4e5f6... --output downloaded-file.txt
6. Check Status
zephyrfs status
zephyrfs status --detailed --watch 5
Commands
init - Initialize Node
Initialize a new ZephyrFS node with configuration.
zephyrfs init [OPTIONS]
Options:
-n, --name <NAME> Node name (optional)
-d, --data-dir <DIR> Data directory path
-p, --port <PORT> Listen port for the node
-s, --storage <GB> Maximum storage allocation in GB
--no-interactive Skip interactive configuration
join - Join Network
Connect to an existing ZephyrFS network.
zephyrfs join <BOOTSTRAP_PEER> [OPTIONS]
Arguments:
<BOOTSTRAP_PEER> Bootstrap peer address (host:port)
Options:
-t, --timeout <SECS> Timeout in seconds [default: 30]
--skip-test Skip connectivity test
upload - Upload Files
Upload files to the distributed network.
zephyrfs upload <FILE> [OPTIONS]
Arguments:
<FILE> File path to upload
Options:
-n, --name <NAME> Custom file name
--progress Show progress bar [default: true]
--verify Verify upload after completion
download - Download Files
Download files from the network by hash.
zephyrfs download <FILE_HASH> [OPTIONS]
Arguments:
<FILE_HASH> File hash to download
Options:
-o, --output <PATH> Output file path
--force Overwrite existing file
--progress Show progress bar [default: true]
--verify Verify download integrity [default: true]
list - List Files
List files available in the network.
zephyrfs list [OPTIONS]
Options:
-l, --long Show detailed information
-s, --sort <COLUMN> Sort by column (name, size, date, chunks) [default: name]
-r, --reverse Reverse sort order
-f, --filter <PATTERN> Filter by name pattern
--format <FORMAT> Output format (table, json, csv) [default: table]
status - Node Status
Show node status and network information.
zephyrfs status [OPTIONS]
Options:
-d, --detailed Show detailed status information
--format <FORMAT> Output format (table, json) [default: table]
-r, --watch <SECS> Refresh interval in seconds (0 for single check) [default: 0]
Configuration
ZephyrFS CLI uses a configuration file to store node settings. The default location is:
- Linux/macOS:
~/.config/zephyrfs/config.yaml - Windows:
%APPDATA%\\zephyrfs\\config.yaml
Configuration File Format
node:
id: null
name: "my-zephyr-node"
data_dir: "~/.zephyrfs"
listen_port: 8080
network:
bootstrap_peers:
- "127.0.0.1:8081"
- "127.0.0.1:8082"
max_connections: 50
connection_timeout: 30
storage:
max_storage_gb: 10
chunk_size_mb: 1
replication_factor: 3
coordinator:
endpoint: "http://127.0.0.1:9000"
timeout: 30
retry_attempts: 3
TOML Configuration
You can also use TOML format by saving as config.toml:
[node]
name = "my-zephyr-node"
data_dir = "~/.zephyrfs"
listen_port = 8080
[network]
bootstrap_peers = ["127.0.0.1:8081", "127.0.0.1:8082"]
max_connections = 50
connection_timeout = 30
[storage]
max_storage_gb = 10
chunk_size_mb = 1
replication_factor = 3
[coordinator]
endpoint = "http://127.0.0.1:9000"
timeout = 30
retry_attempts = 3
Examples
Basic File Operations
# Initialize node with 100GB storage
zephyrfs init --storage 100 --name production-node
# Join production network
zephyrfs join prod.zephyrfs.net:8081
# Upload important files
zephyrfs upload documents.tar.gz --verify
zephyrfs upload photos/ --name family-photos
# List all files with details
zephyrfs list --long --sort date --reverse
# Download specific file
zephyrfs download abc123... --output restored-documents.tar.gz
Monitoring and Maintenance
# Watch node status in real-time
zephyrfs status --detailed --watch 10
# Export metrics for analysis
zephyrfs status --format json > node-metrics.json
# Check network connectivity
zephyrfs join test.zephyrfs.net:8081 --skip-test false
Batch Operations
# Upload multiple files
for file in /data/*.backup; do
zephyrfs upload "$file" --verify
done
# List files in CSV format for processing
zephyrfs list --format csv > file-inventory.csv
Performance
Benchmarking
Run performance benchmarks:
cargo bench
This will generate HTML reports in target/criterion/ with detailed performance analysis.
Metrics
The CLI automatically collects performance metrics including:
- Command execution times
- Network request latencies
- File transfer speeds
- Memory and CPU usage
- Cache hit rates
View current metrics:
zephyrfs status --detailed --format json
Testing
Unit Tests
cargo test
Integration Tests
cargo test --test integration_tests
Note: Some integration tests require running ZephyrFS nodes and are marked with #[ignore]. To run them:
cargo test --test integration_tests -- --ignored
Troubleshooting
Common Issues
Connection Refused
Error: Failed to connect to node
- Ensure the ZephyrFS node is running
- Check the listen port in configuration
- Verify firewall settings
File Not Found
Error: File not found: abc123...
- File may have been removed from the network
- Check file hash is correct
- Try listing files to see what's available
Configuration Error
Error: Failed to parse YAML config
- Validate YAML/TOML syntax
- Check file permissions
- Use
--configflag to specify custom location
Debug Mode
Enable verbose logging:
zephyrfs --verbose <command>
Log Files
Check logs in the data directory:
~/.zephyrfs/logs/zephyrfs-cli.log
Development
Building from Source
git clone https://github.com/ZephyrFS/zephyrfs-cli.git
cd zephyrfs-cli
cargo build
Running Tests
cargo test --all-features
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Run tests and benchmarks
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Related Projects
- zephyrfs-node - Core P2P storage node
- zephyrfs-coordinator - Network coordination service
- zephyrfs-proto - Protocol definitions
- zephyrfs-deploy - Deployment configurations
View source
| 1 | # ZephyrFS CLI |
| 2 | |
| 3 | Command-line interface for ZephyrFS distributed P2P storage network. |
| 4 | |
| 5 | ## Features |
| 6 | |
| 7 | - =� **Easy Setup**: Initialize and configure nodes with interactive prompts |
| 8 | - = **Network Management**: Join and manage P2P network connections |
| 9 | - =� **File Operations**: Upload, download, and list files across the network |
| 10 | - =� **Monitoring**: Built-in metrics and status monitoring |
| 11 | - � **Performance**: Benchmarking and performance analysis tools |
| 12 | - =' **Configuration**: YAML/TOML configuration file support |
| 13 | |
| 14 | ## Installation |
| 15 | |
| 16 | ### From Source |
| 17 | |
| 18 | ```bash |
| 19 | git clone https://github.com/ZephyrFS/zephyrfs-cli.git |
| 20 | cd zephyrfs-cli |
| 21 | cargo build --release |
| 22 | ``` |
| 23 | |
| 24 | The compiled binary will be available at `target/release/zephyrfs`. |
| 25 | |
| 26 | ### Using Cargo |
| 27 | |
| 28 | ```bash |
| 29 | cargo install zephyrfs-cli |
| 30 | ``` |
| 31 | |
| 32 | ## Quick Start |
| 33 | |
| 34 | ### 1. Initialize a Node |
| 35 | |
| 36 | ```bash |
| 37 | # Interactive setup |
| 38 | zephyrfs init |
| 39 | |
| 40 | # Non-interactive with options |
| 41 | zephyrfs init --name my-node --port 8080 --storage 50 |
| 42 | ``` |
| 43 | |
| 44 | ### 2. Join a Network |
| 45 | |
| 46 | ```bash |
| 47 | zephyrfs join 192.168.1.100:8081 |
| 48 | ``` |
| 49 | |
| 50 | ### 3. Upload Files |
| 51 | |
| 52 | ```bash |
| 53 | zephyrfs upload /path/to/file.txt |
| 54 | zephyrfs upload large-file.zip --verify |
| 55 | ``` |
| 56 | |
| 57 | ### 4. List Files |
| 58 | |
| 59 | ```bash |
| 60 | zephyrfs list |
| 61 | zephyrfs list --long --sort size |
| 62 | ``` |
| 63 | |
| 64 | ### 5. Download Files |
| 65 | |
| 66 | ```bash |
| 67 | zephyrfs download a1b2c3d4e5f6... --output downloaded-file.txt |
| 68 | ``` |
| 69 | |
| 70 | ### 6. Check Status |
| 71 | |
| 72 | ```bash |
| 73 | zephyrfs status |
| 74 | zephyrfs status --detailed --watch 5 |
| 75 | ``` |
| 76 | |
| 77 | ## Commands |
| 78 | |
| 79 | ### `init` - Initialize Node |
| 80 | |
| 81 | Initialize a new ZephyrFS node with configuration. |
| 82 | |
| 83 | ```bash |
| 84 | zephyrfs init [OPTIONS] |
| 85 | |
| 86 | Options: |
| 87 | -n, --name <NAME> Node name (optional) |
| 88 | -d, --data-dir <DIR> Data directory path |
| 89 | -p, --port <PORT> Listen port for the node |
| 90 | -s, --storage <GB> Maximum storage allocation in GB |
| 91 | --no-interactive Skip interactive configuration |
| 92 | ``` |
| 93 | |
| 94 | ### `join` - Join Network |
| 95 | |
| 96 | Connect to an existing ZephyrFS network. |
| 97 | |
| 98 | ```bash |
| 99 | zephyrfs join <BOOTSTRAP_PEER> [OPTIONS] |
| 100 | |
| 101 | Arguments: |
| 102 | <BOOTSTRAP_PEER> Bootstrap peer address (host:port) |
| 103 | |
| 104 | Options: |
| 105 | -t, --timeout <SECS> Timeout in seconds [default: 30] |
| 106 | --skip-test Skip connectivity test |
| 107 | ``` |
| 108 | |
| 109 | ### `upload` - Upload Files |
| 110 | |
| 111 | Upload files to the distributed network. |
| 112 | |
| 113 | ```bash |
| 114 | zephyrfs upload <FILE> [OPTIONS] |
| 115 | |
| 116 | Arguments: |
| 117 | <FILE> File path to upload |
| 118 | |
| 119 | Options: |
| 120 | -n, --name <NAME> Custom file name |
| 121 | --progress Show progress bar [default: true] |
| 122 | --verify Verify upload after completion |
| 123 | ``` |
| 124 | |
| 125 | ### `download` - Download Files |
| 126 | |
| 127 | Download files from the network by hash. |
| 128 | |
| 129 | ```bash |
| 130 | zephyrfs download <FILE_HASH> [OPTIONS] |
| 131 | |
| 132 | Arguments: |
| 133 | <FILE_HASH> File hash to download |
| 134 | |
| 135 | Options: |
| 136 | -o, --output <PATH> Output file path |
| 137 | --force Overwrite existing file |
| 138 | --progress Show progress bar [default: true] |
| 139 | --verify Verify download integrity [default: true] |
| 140 | ``` |
| 141 | |
| 142 | ### `list` - List Files |
| 143 | |
| 144 | List files available in the network. |
| 145 | |
| 146 | ```bash |
| 147 | zephyrfs list [OPTIONS] |
| 148 | |
| 149 | Options: |
| 150 | -l, --long Show detailed information |
| 151 | -s, --sort <COLUMN> Sort by column (name, size, date, chunks) [default: name] |
| 152 | -r, --reverse Reverse sort order |
| 153 | -f, --filter <PATTERN> Filter by name pattern |
| 154 | --format <FORMAT> Output format (table, json, csv) [default: table] |
| 155 | ``` |
| 156 | |
| 157 | ### `status` - Node Status |
| 158 | |
| 159 | Show node status and network information. |
| 160 | |
| 161 | ```bash |
| 162 | zephyrfs status [OPTIONS] |
| 163 | |
| 164 | Options: |
| 165 | -d, --detailed Show detailed status information |
| 166 | --format <FORMAT> Output format (table, json) [default: table] |
| 167 | -r, --watch <SECS> Refresh interval in seconds (0 for single check) [default: 0] |
| 168 | ``` |
| 169 | |
| 170 | ## Configuration |
| 171 | |
| 172 | ZephyrFS CLI uses a configuration file to store node settings. The default location is: |
| 173 | - Linux/macOS: `~/.config/zephyrfs/config.yaml` |
| 174 | - Windows: `%APPDATA%\\zephyrfs\\config.yaml` |
| 175 | |
| 176 | ### Configuration File Format |
| 177 | |
| 178 | ```yaml |
| 179 | node: |
| 180 | id: null |
| 181 | name: "my-zephyr-node" |
| 182 | data_dir: "~/.zephyrfs" |
| 183 | listen_port: 8080 |
| 184 | |
| 185 | network: |
| 186 | bootstrap_peers: |
| 187 | - "127.0.0.1:8081" |
| 188 | - "127.0.0.1:8082" |
| 189 | max_connections: 50 |
| 190 | connection_timeout: 30 |
| 191 | |
| 192 | storage: |
| 193 | max_storage_gb: 10 |
| 194 | chunk_size_mb: 1 |
| 195 | replication_factor: 3 |
| 196 | |
| 197 | coordinator: |
| 198 | endpoint: "http://127.0.0.1:9000" |
| 199 | timeout: 30 |
| 200 | retry_attempts: 3 |
| 201 | ``` |
| 202 | |
| 203 | ### TOML Configuration |
| 204 | |
| 205 | You can also use TOML format by saving as `config.toml`: |
| 206 | |
| 207 | ```toml |
| 208 | [node] |
| 209 | name = "my-zephyr-node" |
| 210 | data_dir = "~/.zephyrfs" |
| 211 | listen_port = 8080 |
| 212 | |
| 213 | [network] |
| 214 | bootstrap_peers = ["127.0.0.1:8081", "127.0.0.1:8082"] |
| 215 | max_connections = 50 |
| 216 | connection_timeout = 30 |
| 217 | |
| 218 | [storage] |
| 219 | max_storage_gb = 10 |
| 220 | chunk_size_mb = 1 |
| 221 | replication_factor = 3 |
| 222 | |
| 223 | [coordinator] |
| 224 | endpoint = "http://127.0.0.1:9000" |
| 225 | timeout = 30 |
| 226 | retry_attempts = 3 |
| 227 | ``` |
| 228 | |
| 229 | ## Examples |
| 230 | |
| 231 | ### Basic File Operations |
| 232 | |
| 233 | ```bash |
| 234 | # Initialize node with 100GB storage |
| 235 | zephyrfs init --storage 100 --name production-node |
| 236 | |
| 237 | # Join production network |
| 238 | zephyrfs join prod.zephyrfs.net:8081 |
| 239 | |
| 240 | # Upload important files |
| 241 | zephyrfs upload documents.tar.gz --verify |
| 242 | zephyrfs upload photos/ --name family-photos |
| 243 | |
| 244 | # List all files with details |
| 245 | zephyrfs list --long --sort date --reverse |
| 246 | |
| 247 | # Download specific file |
| 248 | zephyrfs download abc123... --output restored-documents.tar.gz |
| 249 | ``` |
| 250 | |
| 251 | ### Monitoring and Maintenance |
| 252 | |
| 253 | ```bash |
| 254 | # Watch node status in real-time |
| 255 | zephyrfs status --detailed --watch 10 |
| 256 | |
| 257 | # Export metrics for analysis |
| 258 | zephyrfs status --format json > node-metrics.json |
| 259 | |
| 260 | # Check network connectivity |
| 261 | zephyrfs join test.zephyrfs.net:8081 --skip-test false |
| 262 | ``` |
| 263 | |
| 264 | ### Batch Operations |
| 265 | |
| 266 | ```bash |
| 267 | # Upload multiple files |
| 268 | for file in /data/*.backup; do |
| 269 | zephyrfs upload "$file" --verify |
| 270 | done |
| 271 | |
| 272 | # List files in CSV format for processing |
| 273 | zephyrfs list --format csv > file-inventory.csv |
| 274 | ``` |
| 275 | |
| 276 | ## Performance |
| 277 | |
| 278 | ### Benchmarking |
| 279 | |
| 280 | Run performance benchmarks: |
| 281 | |
| 282 | ```bash |
| 283 | cargo bench |
| 284 | ``` |
| 285 | |
| 286 | This will generate HTML reports in `target/criterion/` with detailed performance analysis. |
| 287 | |
| 288 | ### Metrics |
| 289 | |
| 290 | The CLI automatically collects performance metrics including: |
| 291 | - Command execution times |
| 292 | - Network request latencies |
| 293 | - File transfer speeds |
| 294 | - Memory and CPU usage |
| 295 | - Cache hit rates |
| 296 | |
| 297 | View current metrics: |
| 298 | ```bash |
| 299 | zephyrfs status --detailed --format json |
| 300 | ``` |
| 301 | |
| 302 | ## Testing |
| 303 | |
| 304 | ### Unit Tests |
| 305 | |
| 306 | ```bash |
| 307 | cargo test |
| 308 | ``` |
| 309 | |
| 310 | ### Integration Tests |
| 311 | |
| 312 | ```bash |
| 313 | cargo test --test integration_tests |
| 314 | ``` |
| 315 | |
| 316 | Note: Some integration tests require running ZephyrFS nodes and are marked with `#[ignore]`. To run them: |
| 317 | |
| 318 | ```bash |
| 319 | cargo test --test integration_tests -- --ignored |
| 320 | ``` |
| 321 | |
| 322 | ## Troubleshooting |
| 323 | |
| 324 | ### Common Issues |
| 325 | |
| 326 | **Connection Refused** |
| 327 | ``` |
| 328 | Error: Failed to connect to node |
| 329 | ``` |
| 330 | - Ensure the ZephyrFS node is running |
| 331 | - Check the listen port in configuration |
| 332 | - Verify firewall settings |
| 333 | |
| 334 | **File Not Found** |
| 335 | ``` |
| 336 | Error: File not found: abc123... |
| 337 | ``` |
| 338 | - File may have been removed from the network |
| 339 | - Check file hash is correct |
| 340 | - Try listing files to see what's available |
| 341 | |
| 342 | **Configuration Error** |
| 343 | ``` |
| 344 | Error: Failed to parse YAML config |
| 345 | ``` |
| 346 | - Validate YAML/TOML syntax |
| 347 | - Check file permissions |
| 348 | - Use `--config` flag to specify custom location |
| 349 | |
| 350 | ### Debug Mode |
| 351 | |
| 352 | Enable verbose logging: |
| 353 | |
| 354 | ```bash |
| 355 | zephyrfs --verbose <command> |
| 356 | ``` |
| 357 | |
| 358 | ### Log Files |
| 359 | |
| 360 | Check logs in the data directory: |
| 361 | - `~/.zephyrfs/logs/zephyrfs-cli.log` |
| 362 | |
| 363 | ## Development |
| 364 | |
| 365 | ### Building from Source |
| 366 | |
| 367 | ```bash |
| 368 | git clone https://github.com/ZephyrFS/zephyrfs-cli.git |
| 369 | cd zephyrfs-cli |
| 370 | cargo build |
| 371 | ``` |
| 372 | |
| 373 | ### Running Tests |
| 374 | |
| 375 | ```bash |
| 376 | cargo test --all-features |
| 377 | ``` |
| 378 | |
| 379 | ### Contributing |
| 380 | |
| 381 | 1. Fork the repository |
| 382 | 2. Create a feature branch |
| 383 | 3. Make your changes |
| 384 | 4. Add tests |
| 385 | 5. Run tests and benchmarks |
| 386 | 6. Submit a pull request |
| 387 | |
| 388 | ## License |
| 389 | |
| 390 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 391 | |
| 392 | ## Related Projects |
| 393 | |
| 394 | - [zephyrfs-node](https://github.com/ZephyrFS/zephyrfs-node) - Core P2P storage node |
| 395 | - [zephyrfs-coordinator](https://github.com/ZephyrFS/zephyrfs-coordinator) - Network coordination service |
| 396 | - [zephyrfs-proto](https://github.com/ZephyrFS/zephyrfs-proto) - Protocol definitions |
| 397 | - [zephyrfs-deploy](https://github.com/ZephyrFS/zephyrfs-deploy) - Deployment configurations |