Skip to content

Command Line

Blink provides a powerful command-line interface (CLI) for watching directories and receiving file system events.

Basic Usage

The simplest way to use Blink is to watch the current directory:

blink

This will start Blink with default settings, watching the current directory for changes and serving events on http://localhost:12345/events.

Command-line Options

Blink supports the following command-line options:

Core Options

  • --path: Directory path to watch for changes (must be a valid directory) (default: ".")
  • --allowed-origin: Value for Access-Control-Allow-Origin header (default: "*")
  • --event-addr: Address to serve events on ([host][:port]) (default: ":12345")
  • --event-path: URL path for the event stream (default: "/events")
  • --stream-method: Method for streaming events (sse, websocket, both) (default: "sse")
  • --refresh: Refresh duration for events (default: 100ms)
  • --verbose: Enable verbose logging (default: false)
  • --max-procs: Maximum number of CPUs to use (default: all available)
  • --config: Path to configuration file (default: $HOME/.blink.yaml)
  • --help: Show help

Filtering Options

  • --include: Include patterns for files (e.g., ".js,.css,*.html")
  • --exclude: Exclude patterns for files (e.g., "node_modules,*.tmp")
  • --events: Include event types (e.g., "write,create")
  • --ignore: Ignore event types (e.g., "chmod")

Webhook Options

  • --webhook-url: URL for the webhook
  • --webhook-method: HTTP method for the webhook (default: "POST")
  • --webhook-headers: Headers for the webhook (format: "key1:value1,key2:value2")
  • --webhook-timeout: Timeout for the webhook (default: 5s)
  • --webhook-debounce-duration: Debounce duration for the webhook (default: 0s)
  • --webhook-max-retries: Maximum number of retries for the webhook (default: 3)

Subcommands

config

The config subcommand is used to manage configuration:

# List all configuration values
blink config list

# Get a specific configuration value
blink config get path

# Set a configuration value
blink config set path /path/to/watch

version

The version subcommand shows the version information:

blink version

Examples

Basic Examples

# Watch the current directory
blink

# Watch a specific directory
blink --path /path/to/watch

# Use a different port
blink --event-addr :8080

# Enable verbose logging
blink --verbose

Streaming Examples

# Use WebSockets for event streaming
blink --stream-method websocket

# Use Server-Sent Events (SSE) for event streaming (default)
blink --stream-method sse

# Use both WebSockets and SSE simultaneously
blink --stream-method both

When using --stream-method both, Blink will serve:

  • SSE events at the path specified by --event-path (default: /events)
  • WebSocket events at the same path with /ws appended (default: /events/ws)

Filtering Examples

# Only watch for changes to JavaScript files
blink --include "*.js"

# Ignore node_modules directory
blink --exclude "node_modules"

# Only trigger on write events
blink --events "write"

# Ignore chmod events
blink --ignore "chmod"

# Complex filtering
blink --include "*.js,*.css,*.html" --exclude "node_modules,*.tmp" --events "write,create" --ignore "chmod"

Webhook Examples

# Send webhooks to a URL
blink --webhook-url "https://example.com/webhook"

# Use a specific HTTP method
blink --webhook-method "PUT"

# Add custom headers
blink --webhook-headers "Authorization:Bearer token,Content-Type:application/json"

# Set timeout and retry options
blink --webhook-timeout 10s --webhook-max-retries 5

# Debounce webhooks
blink --webhook-debounce-duration 500ms

# Combine with filters
blink --include "*.js" --events "write" --webhook-url "https://example.com/webhook"

Configuration Examples

# Use a specific configuration file
blink --config /path/to/config.yaml

# List all configuration values
blink config list

# Get a specific configuration value
blink config get path

# Set a configuration value
blink config set path /path/to/watch