Skip to content

CLI Reference

CLI Reference

Back to README

The bloqr-compiler CLI is the primary entry-point for compiling filter lists locally with full control over the transformation pipeline, HTTP fetching, filtering, and output.

Installation

Terminal window
# Run directly with Deno (no install)
deno run --allow-read --allow-write --allow-net jsr:@jk-com/bloqr-compiler/cli -c config.json -o output.txt
# Install globally
deno install --allow-read --allow-write --allow-net -n bloqr-compiler jsr:@jk-com/bloqr-compiler/cli

Usage

bloqr-compiler [options]

Options

General

FlagShortTypeDescription
--config <file>-cstringPath to the compiler configuration file
--input <source>-istring[]URL or file path to compile (repeatable)
--input-type <type>-thosts|adblockInput format [default: hosts]
--verbose-vbooleanEnable verbose logging
--benchmark-bbooleanShow performance benchmark report
--progress-pbooleanShow real-time progress events during compilation
--use-queue-qbooleanSubmit job to async queue (requires worker API)
--priority <level>standard|highQueue priority [default: standard]
--versionbooleanShow version number
--help-hbooleanShow help

Either --config or --input must be provided (but not both).


Output

FlagShortTypeDescription
--output <file>-ostringOutput file path [required unless --stdout]
--stdoutbooleanWrite output to stdout instead of a file
--appendbooleanAppend to output file instead of overwriting
--format <format>stringOutput format. Supported values: adblock, hosts, dnsmasq, doh, json, pihole, unbound. [not yet wired in CLI — use the programmatic API’s createFormatter / formatOutput for now]
--name <file>stringCompare output against an existing file and print a summary of added/removed rules
--max-rules <n>numberTruncate output to at most n rules

--stdout and --output are mutually exclusive. --format is parsed but not yet wired into the CLI output path; use the programmatic createFormatter / formatOutput API instead.


Transformation Control

When no transformation flags are specified, the default pipeline is used: RemoveCommentsDeduplicateCompressValidateTrimLinesInsertFinalNewLine

FlagTypeDescription
--no-commentsbooleanSkip the RemoveComments transformation
--no-deduplicatebooleanSkip the Deduplicate transformation
--no-compressbooleanSkip the Compress transformation
--no-validatebooleanSkip the Validate transformation
--allow-ipbooleanReplace Validate with ValidateAllowIp (keeps IP-address rules)
--invert-allowbooleanAppend the InvertAllow transformation
--remove-modifiersbooleanAppend the RemoveModifiers transformation
--convert-to-asciibooleanAppend the ConvertToAscii transformation
--transformation <name>string[]Override the entire pipeline (repeatable). When provided, all other transformation flags are ignored.

Available transformation names for --transformation:

NameDescription
RemoveCommentsRemove ! and # comment lines
DeduplicateRemove duplicate rules
CompressConvert hosts-format rules to adblock syntax and remove redundant entries
ValidateRemove dangerous or incompatible rules (strips IP-address rules)
ValidateAllowIpLike Validate but keeps IP-address rules
InvertAllowConvert blocking rules to allow/exception rules
RemoveModifiersStrip unsupported modifiers ($third-party, $document, etc.)
TrimLinesRemove leading/trailing whitespace from each line
InsertFinalNewLineEnsure the output ends with a newline
RemoveEmptyLinesRemove blank lines
ConvertToAsciiConvert non-ASCII hostnames to Punycode
ConflictDetectionDetect and optionally auto-resolve conflicting block/allow rules for the same domain
RuleOptimizerOptimize rules for smaller file size and better matching performance

See TRANSFORMATIONS.md for detailed descriptions of each transformation.


Filtering

These flags apply globally to the compiled output (equivalent to IConfiguration.exclusions / inclusions).

FlagTypeDescription
--exclude <pattern>string[]Exclude rules matching the pattern (repeatable). Supports exact strings, * wildcards, and /regex/ patterns. Maps to exclusions[].
--exclude-from <file>string[]Load exclusion patterns from a file (repeatable). Maps to exclusions_sources[].
--include <pattern>string[]Include only rules matching the pattern (repeatable). Maps to inclusions[].
--include-from <file>string[]Load inclusion patterns from a file (repeatable). Maps to inclusions_sources[].

When used with --config, these flags are overlaid on top of any exclusions / inclusions already defined in the config file.


Authentication (Queue Mode)

These flags are used when submitting jobs to the remote worker API via --use-queue. They are not required for local-only compilation. See the CLI Authentication Guide for full details, CI/CD examples, and security best practices.

FlagTypeDescription
--api-key <key>stringAPI key for worker API requests (starts with blq_; legacy abc_ also accepted)
--bearer-token <jwt>stringClerk JWT bearer token for worker API requests
--api-url <url>stringBase URL of the worker API [default: https://bloqr-backend.jk-com.workers.dev]

--api-key and --bearer-token are mutually exclusive — choose one per invocation. A warning is emitted if auth flags are used without --use-queue.


Networking

FlagTypeDescription
--timeout <ms>numberHTTP request timeout in milliseconds
--retries <n>numberNumber of HTTP retry attempts (uses exponential backoff)
--user-agent <string>stringCustom User-Agent header for HTTP requests

Examples

Basic compilation from a config file

Terminal window
bloqr-compiler -c config.json -o output.txt

Compile from multiple URL sources

Terminal window
bloqr-compiler \
-i https://example.org/hosts.txt \
-i https://example.org/extra.txt \
-o output.txt

Stream output to stdout

Terminal window
bloqr-compiler -i https://example.org/hosts.txt --stdout

Skip specific transformations

Terminal window
# Keep IP-address rules and skip compression
bloqr-compiler -c config.json -o output.txt --allow-ip --no-compress
# Skip deduplication (faster, output may contain duplicates)
bloqr-compiler -c config.json -o output.txt --no-deduplicate

Explicit transformation pipeline

Terminal window
# Only remove comments and deduplicate — no compression or validation
bloqr-compiler -i https://example.org/hosts.txt -o output.txt \
--transformation RemoveComments \
--transformation Deduplicate \
--transformation TrimLines \
--transformation InsertFinalNewLine

Filtering rules from output

Terminal window
# Exclude specific domain patterns
bloqr-compiler -c config.json -o output.txt \
--exclude "*.cdn.example.com" \
--exclude "ads.example.org"
# Load exclusion list from a file
bloqr-compiler -c config.json -o output.txt \
--exclude-from my-whitelist.txt
# Include only rules matching a pattern
bloqr-compiler -c config.json -o output.txt \
--include "*.example.com"
# Load inclusion list from a file
bloqr-compiler -c config.json -o output.txt \
--include-from my-allowlist.txt

Limit output size

Terminal window
# Truncate to first 50,000 rules
bloqr-compiler -c config.json -o output.txt --max-rules 50000

Compare output against a previous build

Terminal window
bloqr-compiler -c config.json -o output.txt --name output.txt.bak
# Output:
# Comparison with output.txt.bak:
# Added: +42 rules
# Removed: -7 rules
# Net: +35 rules

Append to an existing output file

Terminal window
bloqr-compiler -i extra.txt -o output.txt --append

Authenticated queue compilation

Terminal window
# Submit to remote queue with API key authentication
bloqr-compiler -c config.json -o output.txt \
--use-queue \
--api-key blq_Xk9mP2nLqR5tV8wZ...
# Use a local dev worker
bloqr-compiler -c config.json -o output.txt \
--use-queue \
--api-key blq_Xk9mP2nLqR5tV8wZ... \
--api-url http://localhost:8787

Custom networking options

Terminal window
bloqr-compiler -c config.json -o output.txt \
--timeout 15000 \
--retries 5 \
--user-agent "MyListBot/1.0"

Verbose benchmarking

Terminal window
bloqr-compiler -c config.json -o output.txt --verbose --benchmark

Configuration File

When using --config, the compiler reads an IConfiguration JSON file. The CLI filtering and transformation flags are applied as an overlay on top of what is defined in that file.

See CONFIGURATION.md for the full configuration file reference.