Skip to content

Add native CLI tool for terminal interaction with CrossPaste #3828

@guiyanakuang

Description

@guiyanakuang

Summary

Add a Kotlin/Native CLI tool (crosspaste) that allows users to interact with the locally running CrossPaste application from the terminal. The CLI communicates with the app via HTTP API using token-based authentication.

Features

CLI Commands

  • crosspaste status — Show app status (version, port, device count, paste count)
  • crosspaste paste [id] — View the most recent paste or a specific paste by ID
  • crosspaste history [--limit] [--type] [--favorite] — List recent paste history with filtering
  • crosspaste search <query> [--limit] [--type] — Full-text search paste history
  • crosspaste copy <text> — Copy text to clipboard via CrossPaste
  • crosspaste delete <id> — Delete a paste by ID
  • crosspaste fav <id> — Toggle favorite status
  • crosspaste devices — List paired devices with connection status
  • crosspaste config / crosspaste config set <key> <value> — View/update configuration
  • crosspaste tags / tags create <name> / tags delete <id> — Manage paste tags
  • crosspaste version — Show CLI and app versions
  • crosspaste --json <command> — JSON output mode for scripting/piping
  • crosspaste --generate-completion=(bash|zsh|fish) — Shell completion

Architecture

  • Kotlin/Native binary — no JVM required at runtime
  • Koin DI for dependency injection and testability
  • Token-based auth — app generates a token file on startup, CLI reads it for Bearer auth
  • Platform-aware paths — mirrors the desktop app's path resolution exactly (macOS, Linux, Windows)
  • Custom storage path support — reads appConfig.json to resolve non-default data directories

Tech Stack

  • Clikt 5.1.0 for command parsing
  • Ktor CIO Client for HTTP communication
  • Koin 4.1.1 for dependency injection
  • Okio for file system operations

App-Side Changes

  • New CliTokenManager — generates and validates CLI auth tokens
  • New CliRouting — HTTP routes under /cli/* with localhost + Bearer token auth
  • New CLI DTOs — StatusResponse, PasteSummaryDto, ManagementDto
  • New error codes — CLI_FORBIDDEN, CLI_NOT_FOUND, CLI_INVALID_REQUEST
  • New SQLDelight query — getActiveCount for paste statistics

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions