6. Command Line Interface (CLI)

6.1. Introduction

blunderDB ships a full command line interface (CLI) in the same executable as the graphical interface. The CLI is especially useful for:

  • bulk import of matches: import an entire directory of match files (XG, SGF, MAT, BGF…) in a single command,

  • automation: integrate blunderDB into shell scripts for regular backups, scheduled exports, or processing pipelines,

  • server usage: manage databases on machines without a graphical environment,

  • quick inspection: check the contents or integrity of a database without launching the graphical interface.

The CLI shares exactly the same database format as the graphical interface. Any operation performed via the CLI is immediately visible in the GUI and vice versa.

6.2. General syntax

The mode is detected automatically: if the first argument is a CLI command, blunderDB launches in headless mode, otherwise it launches the graphical interface.

# Mode graphique (aucun argument)
./blunderdb

# Mode CLI
./blunderdb <commande> [options]

6.3. Available commands

Command

Description

create

Create a new database.

import

Import data (match, position, batch).

export

Export data.

search

Search positions with filters.

list

Display database contents.

match

Display match positions and analysis.

info

Display database metadata.

edit

Edit database metadata.

verify

Verify database integrity.

delete

Delete data.

help

Show help.

version

Show version.

Each command accepts the --help option to display its detailed help.

6.4. create — Create a database

Create a new database file with optional metadata.

./blunderdb create --db <chemin> [--user <nom>] [--description <texte>] [--force]

Options:

  • --db — Path to the database file to create (required).

  • --user — Database owner name.

  • --description — Database description.

  • --force — Overwrite the file if it already exists.

The .db extension is added automatically if missing. Parent directories are created as needed.

Example:

./blunderdb create --db mes_matchs.db --user "Jean" --description "Matchs de tournoi 2025"

6.5. import — Import data

Import match or position files into the database.

./blunderdb import --db <chemin> --type <type> [options]

Options:

  • --db — Path to the database (required).

  • --type — Import type: match, position or batch (required).

  • --file — File to import (for match and position).

  • --dir — Directory to import (for batch).

  • --recursive — Recursively scan subdirectories (default: yes).

6.5.1. Import a match

Supported formats: eXtreme Gammon (.xg, .xgp), GNUbg (.sgf), Jellyfish (.mat, .txt) and BGBlitz (.bgf).

./blunderdb import --db base.db --type match --file match.xg

6.5.2. Import positions

Import positions from a text file (one JSON position per line):

./blunderdb import --db base.db --type position --file positions.txt

6.5.3. Batch import

Import all match files from a directory in a single operation. This is the most efficient method for importing a large number of matches.

# Import récursif (par défaut)
./blunderdb import --db base.db --type batch --dir ./matchs/

# Import non récursif
./blunderdb import --db base.db --type batch --dir ./matchs/ --recursive=false

A summary table shows for each file whether the import succeeded (✓), failed (✗) or was a duplicate (⊘).

6.6. export — Export data

Export database contents to files.

./blunderdb export --db <chemin> --type <type> --file <sortie> [options]

Options:

  • --db — Source database (required).

  • --type — Export type: database, positions or matches (required).

  • --file — Output file (required).

  • --analysis — Include analysis (default: yes).

  • --comments — Include comments (default: yes).

  • --filters — Include filter library (default: yes).

  • --played-moves — Include played moves (default: yes).

  • --matches — Include matches (default: yes).

  • --collections — Include collections (default: no).

  • --collection-ids — Collection IDs to export (comma-separated).

  • --match-ids — Match IDs to export (comma-separated, empty = all).

  • --tournament-ids — Tournament IDs to export (comma-separated).

Examples:

# Export complet de la base
./blunderdb export --db base.db --type database --file sauvegarde.db

# Export des positions en JSON
./blunderdb export --db base.db --type positions --file positions.txt

# Export de matchs spécifiques
./blunderdb export --db base.db --type matches --file selection.db --match-ids 1,3,5

6.7. search — Search positions

Search positions in the database using combinable criteria.

./blunderdb search --db <chemin> [options]

Main options:

  • --db — Database (required).

  • --format — Output format: table, json or xgid (default: table).

  • --limit — Maximum number of results (0 = unlimited).

  • --export — Export results to a new database.

Available filters:

  • --decision — Decision type: checker or cube.

  • --pip-min / --pip-max — Pip count difference range.

  • --winrate-min / --winrate-max — Win rate range (%).

  • --cube — Cube value.

  • --score1 / --score2 — Player scores.

  • --match-length — Match length.

  • --error-min — Minimum equity error.

  • --move-error-min / --move-error-max — Played move error (millipoints).

  • --has-analysis — Only positions with analysis.

  • --off1-min / --off2-min — Minimum checkers off (player 1/2).

  • --match-ids — Filter by match IDs (comma-separated).

  • --tournament-ids — Filter by tournament IDs (comma-separated).

Examples:

# Rechercher les décisions de videau
./blunderdb search --db base.db --decision cube

# Rechercher les positions avec erreur >= 0.1
./blunderdb search --db base.db --error-min 0.1

# Rechercher dans un tournoi et exporter
./blunderdb search --db base.db --tournament-ids 1 --export cubes.db

# Sortie JSON limitée à 10 résultats
./blunderdb search --db base.db --format json --limit 10

6.8. list — List contents

Display database contents.

./blunderdb list --db <chemin> --type <type> [--limit <n>]

Types:

  • matches — List of imported matches.

  • positions — List of positions (limited to 10 by default).

  • stats — Global statistics (positions, analyses, matches, games, moves).

Examples:

# Statistiques de la base
./blunderdb list --db base.db --type stats

# Liste des matchs
./blunderdb list --db base.db --type matches

# Premières 20 positions
./blunderdb list --db base.db --type positions --limit 20

6.9. match — Display a match

Display positions and analysis of an imported match.

./blunderdb match --db <chemin> --id <id_match> [--format <format>] [--output <fichier>]

Options:

  • --db — Database (required).

  • --id — Match ID to display (required).

  • --format — Output format: json, text or summary (default: json).

  • --output — Output file (default: stdout).

Examples:

# Résumé d'un match
./blunderdb match --db base.db --id 1 --format summary

# Détails de chaque position
./blunderdb match --db base.db --id 1 --format text

# Export JSON vers un fichier
./blunderdb match --db base.db --id 1 --output match1.json

6.10. info — Database metadata

Display metadata and statistics of a database.

./blunderdb info --db <chemin> [--format <format>]

Options:

  • --db — Database (required).

  • --format — Output format: text or json (default: text).

Examples:

# Afficher les informations
./blunderdb info --db base.db

# Sortie JSON (pour un script)
./blunderdb info --db base.db --format json

6.11. edit — Edit metadata

Edit the user name or description of a database.

./blunderdb edit --db <chemin> [options]

Options:

  • --db — Database (required).

  • --user — New user name.

  • --description — New description.

  • --clear-user — Clear user name.

  • --clear-description — Clear description.

At least one edit option is required.

Examples:

# Modifier l'utilisateur et la description
./blunderdb edit --db base.db --user "Marie" --description "Ma collection"

# Effacer la description
./blunderdb edit --db base.db --clear-description

6.12. verify — Verify integrity

Verify database integrity and optionally compare a match against its source file.

./blunderdb verify --db <chemin> [--match <id>] [--mat <fichier.mat>]

Options:

  • --db — Database (required).

  • --match — Match ID to verify.

  • --mat — MAT file to compare against (used with --match).

Without --match, the command displays general database statistics. With --match, it verifies the match data and can compare it against the original source file.

Examples:

# Vérification globale
./blunderdb verify --db base.db

# Vérifier un match spécifique
./blunderdb verify --db base.db --match 1

# Comparer avec le fichier source
./blunderdb verify --db base.db --match 1 --mat original.mat

6.13. delete — Delete data

Delete a match and all associated data (games, moves, analyses).

./blunderdb delete --db <chemin> --type match --id <id> [--confirm]

Options:

  • --db — Database (required).

  • --type — Delete type: match (required).

  • --id — ID of the item to delete (required).

  • --confirm — Delete without asking for confirmation.

Examples:

# Supprimer avec confirmation interactive
./blunderdb delete --db base.db --type match --id 1

# Supprimer sans confirmation (pour scripts)
./blunderdb delete --db base.db --type match --id 1 --confirm

6.14. Workflow examples

6.14.1. Import a tournament directory

# Créer une base dédiée au tournoi
./blunderdb create --db tournoi_paris.db --user "Jean" --description "Open de Paris 2025"

# Importer tous les matchs du répertoire
./blunderdb import --db tournoi_paris.db --type batch --dir ./matchs_open_paris/

# Vérifier le résultat
./blunderdb list --db tournoi_paris.db --type stats

6.14.2. Regular backup

# Export complet pour sauvegarde
./blunderdb export --db production.db --type database --file sauvegarde-$(date +%Y%m%d).db

6.14.3. Error analysis

# Extraire les blunders dans une base séparée
./blunderdb search --db production.db --error-min 0.1 --export blunders.db

# Extraire les erreurs de videau
./blunderdb search --db production.db --decision cube --error-min 0.05 --export cube_errors.db

6.15. Exit codes

  • 0 — Success.

  • 1 — Error.

This makes the CLI suitable for use in scripts with error handling:

if ./blunderdb import --db base.db --type match --file match.xg; then
    echo "Import réussi"
else
    echo "Échec de l'import"
    exit 1
fi