ADR-0019: The Command Line Mirrors the API#
Status#
Accepted 2026-12-02
Context#
Many of irtlib’s tasks take files and give files: calibrate a bank from a response file, score examinees on a bank, check a calibration’s fit. With files for responses, abilities and calibrations (ADR-0018), these tasks need no Python. A researcher who works in R or in a shell, a step in a pipeline, or an agent acting for a user can run them as commands, once irtlib has a command line. A command line is a second interface, though, and its options drift from the API’s when the two are written apart.
Decision#
One command,
irtlib, installed with the package as a script and run aspython -m irtlibtoo. It is written with the standard library’sargparse, so it needs no dependency (ADR-0002).It mirrors the API. There is a subcommand per calibrator, estimator and fit statistic, and an option per keyword argument, with hyphens for underscores. A settings object, such as the priors, has one option per field. An option left out is not passed, so every default is the API’s own and is written once. These are the exceptions:
arguments that take Python objects, a grid or
maximum_likelihood’s fallback, are left out;--priorchooses a normal or a uniform ability prior;--seedis therngargument (ADR-0005);draw --examinees Ndraws standard normal abilities, the command line’s one computation.
It is a thin entry point.
irtlib.cliparses the arguments, reads the files, calls the API, writes the files and prints. It sits besideirtlib.plotin the import contract, below__main__.Output:
standard output shows the result’s printed form (ADR-0017);
compareandclassical, which have no result type, print tables in the same layout, anddrawa line naming its file;a file is written only for an option that names one;
a result without a file has no machine-readable form, as no object has two formats (ADR-0018);
each warning prints as one line on standard error, once per message and place, whatever filters the process has set.
Names: the response file’s item names go into the bank a calibration writes, and its examinee names into the abilities file. The fit commands refuse a response file and an abilities file that both name their examinees and list them differently.
Exit status: 0 when the command ran, a calibration that did not converge included; 1 for an error, printed without a traceback; and 2 for a mistake in the command line.
Consequences#
An analysis runs without writing Python. Each command’s help names the options as the API names the arguments, so the API reference explains them.
A keyword argument added to a mirrored call needs its option, and a test compares each command’s help with its call’s signature.
What a command line cannot express stays in Python: custom grids, ability priors other than the normal and the uniform, and a fallback estimator.
Alternatives Considered#
click or typer: a dependency for what
argparsedoes.A
--methodoption in place of a subcommand per method: one command whose options apply to some methods only, whichargparsecould not refuse for the others.A
--jsonoutput of every result: a second format for results that have none.An MCP server: it needs the
mcppackage, and passes data as tool arguments; a command line serves shells, pipelines and agents that run code.