What a program reads#
This page is the interface of hmp for a script or a platform. --format json and
--format csv print the result of a command in a shape that does not move inside a major
version. --format table, the default, is for people and promises nothing.
The envelope#
--format json prints one JSON object on stdout, and nothing else. It has two keys:
{"schema": "hmp.catalog.ls.v1", "data": []}
schema names the command and the version of what data holds. data is an array of rows for
a command that lists, and an object for any other. A listing with nothing to list is an empty
array, never a sentence. Everything else a command says, a solver and a library included, goes
to stderr, so stdout always parses. The result is written once the command is over. A value that
is not a number in JSON, NaN or an infinity, is null, and a path or a date is a string.
--format csv prints the same rows with a header, and an empty listing is the header alone. An
object is key,value lines, or its own table when it holds one: the cases of hmp ls --plan,
the files of hmp example show, the states of hmp catalog reindex. A list in a cell is joined
with ; and a mapping is written key=value, so a cell is always one line.
What is promised#
Inside a major version a field keeps its name and its meaning. A new field can come in a minor
version, so a reader ignores what it does not know. When a field has to change or leave, the
number in schema goes up and the rules of Versions and stability apply. A command marked
experimental below follows the experimental rule of that page. A row marked open can hold more
columns than the ones listed: the columns of a query, a metric the command was asked to rank by.
When a command fails#
A command that fails ends with the code of Exit codes and prints its HMPY.Exxx first on
a line of stderr. Under --format json, stdout also holds an envelope of its own, unless the
command had a result to write:
{"schema": "hmp.error.v1", "data": {"code": "HMPY.E002", "title": "...", "detail": "...", "exit_code": 10}}
A mistake on the command line itself, such as a flag that does not exist, is found before
--format is read, so it only has its line on stderr and exit code 2.
A command that reports a result and a failure writes both: hmp doctor lists its checks and
exits 1 when one is KO, hmp publish --verify lists its differences and exits 1.
What each command writes#
The commands that are not listed print a document that is the result itself, and an envelope
would break it: hmp config template, hmp config resolve, hmp config schema,
hmp config wizard and hmp completion.
The JSON Schema of the result of hmp calibrate ships as
hydromodpy/schema/results/calibrate.v1.json.
Command |
|
|
Fields |
|---|---|---|---|
|
|
object |
|
|
|
object |
|
|
|
object, experimental |
|
|
|
object, experimental |
|
|
|
object, experimental |
|
|
|
object |
|
|
|
object |
|
|
|
rows |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
rows |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
rows, open |
|
|
|
rows |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
rows |
|
|
|
object |
|
|
|
rows, open |
|
|
|
rows |
|
|
|
object |
|
|
|
rows, open |
the columns of the result |
|
|
object |
|
|
|
rows, open |
the columns of the result |
|
|
rows, open |
the columns of the result |
|
|
object |
|
|
|
rows, open |
the columns of the result |
|
|
rows |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
rows |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
rows |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
rows |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
rows |
|
|
|
rows |
|
|
|
object |
|
|
|
rows, open |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
rows |
|
|
|
object |
|
|
|
rows |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|
|
|
object |
|