command line options

Normally CQL can be run just by specifying the name of the CQL file. To run CQL on a CQL file named foo.cql, use
cql foo.cql

Parameters that control how CQL operates are specified in the CQL file itself.

For advanced usage it is sometimes helpful to modify certain CQL parameters without modifying the CQL file. For example, it is sometimes convenient to run the same CQL file can easily be run on different games or with different input files.

For this purpose, CQL supports various command line options. These options follow Unix conventions and consist either of a single letter preceded by a hyphen, or a word preceded by two hyphens. Some of options take one or two arguments following the option name and separated by whitespace. These options override any options set in the CQL file itself.

The command line options are:

option name            examples                                   description
--gamenumber
-g
cql --gamenumber 1 100 foo.cql
cql -g 43597 foo.cql
only consider games with game numbers in the range given by the next one or two numeric command line arguments. Overrides the gamenumber filter in CQL header.
--help cql --help print a help message
--input
-i
cql --input h.pgn foo.cql read games from the PGN file specified in the next command line argument. The .cql> extension may be omitted. Overrides the input CQL parameter
--output
-o
cql --output out.pgn foo.cql write output to the PGN file specified in the next command line argument. Overrides the output CQL parameter
--player cql --player Reti foo.cql Only consider games by player named in next command line argument
--silent cql --silent foo.cql Suppress printing of automatically generated comments
--year cql --year 2000 2010 foo.cql only consider games whose year is in the range given by the following one or two numeric command line arguments

Combining options

The options can be combined. For example,
  cql --input input.pgn --output -output.pgn --gamenumber 100 1000 foo
will read the cql file "foo.cql", using games from "input.pgn" and writing the output to "output.pgn", only examining games 100 through 1000 from "input.pgn".

Syntax errors

Unlike in previous versions of CQL, when a syntax error occurs CQL sometimes attempts to give a useful error message, including the line number and character where it thinks the error occurs. Always check these error messages when tracking down a syntax error.

Using any.cql

The example CQL file any.cql is specifically designed to be run with command line options. This file silently does nothing, which means it can, for instance, select games by a player, e.g.
cql --player Euwe -year 2000 2005 examples/any.cql