Skip to main content

Spacedrive CLI

A comprehensive command-line interface for managing Spacedrive Core with full daemon architecture, real-time monitoring, and cross-device file management.

Features

  • ️ Daemon Architecture: Background daemon with client-server communication
  • Library Management: Create, open, switch, and manage multiple libraries
  • Location Management: Add, remove, and monitor indexed locations with real-time watching
  • ️ Job Management: View, monitor, and control background jobs with live progress
  • Real-time Monitoring: Beautiful TUI for monitoring job progress and system events
  • Indexing Control: Start indexing jobs with different modes (shallow/content/deep)
  • Networking Support: Device pairing, file sharing via Spacedrop
  • Multiple Instances: Run isolated daemon instances for different use cases
  • Comprehensive Logging: Built-in logging with file output for debugging
  • ️ Cross-platform: Works on macOS, Linux, and Windows
  • Rich UI: Colored output, progress bars, and formatted tables

New Modular Architecture Benefits

The refactored daemon architecture provides:
  • Maintainability: Each domain (library, location, job, etc.) is isolated in its own handler module
  • Extensibility: New commands can be added by simply creating a new handler
  • Type Safety: All commands and responses are strongly typed
  • Code Organization: Clear separation between command handling, business logic, and transport
  • Testability: Individual handlers can be unit tested in isolation
  • Performance: Efficient command routing through handler registry

Installation

Also you may create an alias to the cli as sd or spacedrive. Example for sd:

Quick Start

Note: If you haven’t set up the alias, use ./target/debug/sd-cli or ./target/release/sd-cli instead of sd.

Usage

Daemon Management

Daemon Auto-Start (macOS)

Set up the daemon to start automatically on login:
The install command creates a LaunchAgent that starts the daemon on login and restarts it if it crashes. Logs write to your data directory at ~/Library/Application Support/spacedrive/logs/. This works with multiple instances by passing --instance before the daemon command.
Auto-start is currently macOS-only. Linux systemd support is planned.

Multiple Daemon Instances

The CLI supports running multiple isolated daemon instances:

Basic Commands

Library Management

Location Management

Note: Location IDs are UUIDs displayed in the list command. All location operations work with the daemon automatically.

Enhanced Indexing

The new indexing system supports different scopes and persistence modes:
Index Scopes:
  • current: Index only the specified directory (single level)
  • recursive: Index the directory and all subdirectories
Index Modes:
  • shallow: Metadata only (fastest)
  • content: Metadata + content hashing (moderate)
  • deep: Full analysis including media metadata (slowest)
Use Cases:
  • UI Navigation: quick-scan --scope current for instant directory viewing
  • External Browsing: browse --ephemeral for exploring non-managed paths
  • Location Updates: location --scope current to refresh specific directories

Job Management

Job Monitor Features:
  • Live progress bars for running jobs
  • Color-coded status (running: yellow, completed: green, failed: red)
  • ️ Real-time updates every second
  • Automatic cleanup of completed jobs
  • ️ Ctrl+C to exit gracefully

File Operations

System Commands

Networking & Device Management

Real-time Job Monitor

The job monitor provides live progress tracking with beautiful visual indicators:

Monitor Features

  • Multi-job tracking: Monitor all running jobs simultaneously
  • Progress bars: Visual progress indicators with percentage
  • Color coding: Status-based colors (yellow=running, green=completed, red=failed)
  • Real-time updates: Updates every second with latest progress
  • Smart cleanup: Completed jobs automatically marked and removed
  • Job filtering: Option to monitor specific jobs

Sample Output

Indexing Modes

  • Shallow: Fast metadata-only indexing (file names, sizes, dates)
  • Content: Standard indexing with content hashing for deduplication
  • Deep: Comprehensive analysis including media metadata extraction

Examples

Complete Workflow

Multiple Libraries

Batch Indexing

Architecture

The CLI follows a modular architecture with clear separation of concerns:
  • Client: Lightweight CLI that communicates with daemon
  • Daemon: Long-running background service managing Core
  • Handlers: Modular command processors for each domain
  • Transport: JSON-RPC communication over Unix socket
  • Core: Spacedrive Core library for all operations

Benefits

  1. Performance: Daemon keeps Core loaded in memory
  2. Persistence: Operations continue after CLI exits
  3. Concurrency: Multiple CLI clients can connect
  4. Monitoring: Real-time tracking of background tasks
  5. Isolation: Multiple instances for testing