Command line

The cim command: inspect, validate, export, convert to RDF and diff CGMES model sets from a shell. Full option reference and exit codes.

cim is a thin shell over the public API: seven subcommands over a model set given as files, archives or directories.

cargo install cim-kit --features cli
brew install hupe1980/tap/cim-kit    # macOS (Apple Silicon) and Linux

Commands#

CommandDoes
cim info <input>…What a model set contains: files, object counts, profile coverage, findings
cim validate <input>…Structural checks; exits 1 on any error
cim export <input>… --out DIRWrite the model back as CIM/XML
cim rdf <input>… --out DIRExport as RDF, one graph per profile with data
cim diff <base> <target>Compute a dm:DifferenceModel
cim apply <input>… --change F --out DIRApply a change set and write the result
cim schemaWhat the built-in vintages declare

An <input> is a CIM/XML file, a zip archive, or a directory holding either. Several are loaded into one model.

Options#

OptionEffect
-o, --out PATHWhere to write — a directory, or a file for diff
--vintage KEYWhich schema to read against (cgmes3, cgmes2); by default it is detected from the input
--profile KEYRestrict rdf and diff to a profile, e.g. SSH; repeat it for a file that serves several — --profile EQ --profile OP --profile SC writes the one graph a CGMES 2.4.15 Equipment file contains
--change FILEA dm:DifferenceModel for apply; repeat to apply several, in the order given
--assume-profile KEYWhich profile a file's values belong to when it declares none — a document with no md:FullModel
--rule CODEShow only this rule in validate, e.g. CIM0007
--ntriplesWrite N-Triples rather than Turtle
--mergedrdf writes one graph for the whole model, not one per profile
--strictFail on anything the schema does not define
--single-descriptionReport an object described more than once in one file (CIM0005)
--max-input SIZEStop reading after SIZE bytes, archives counted decompressed (default 8GiB; 512MB, 16GiB, unlimited)
--limit NHow many findings to list (default 20; 0 for all)
-q, --quietLess chatter
-h, --helpUsage
-V, --versionWhich release this binary is

Exit status#

0Clean
1The model has errors
2The command was wrong, or could not do its job — including an input over --max-input

An input over the budget writes nothing and says what to try:

cim: input exceeds the 8GiB input budget (8GiB read while reading EQ.xml); rerun with --max-input 32GiB, or --max-input unlimited

cim validate works directly as a CI gate:

cim validate model/ --rule CIM0007 || exit 1

Examples#

$ cim info MicroGrid-Type1-NL-MAS/
== files ==
  20210323T1730Z_1D_NL_EQ_1.xml     EQ+SC   2021-03-23T17:30:00Z
  20210323T1730Z_1D_NL_SSH_1.xml    SSH     2021-03-23T17:30:00Z
  …

== model ==
  objects              602
  values               3632
  Substation           1
  ACLineSegment        5
  PowerTransformer     3

== profile coverage ==
  EQ          247 objects       1577 values
  SSH         114 objects        189 values
  SV           86 objects        213 values

== diagnostics ==
  CIM0006       51
  CIM0014        1
# Either vintage, detected from the document.
cim info CGMES_v2.4.15_MicroGridTestConfiguration_T4_BE_BB_Complete_v2.zip
cim info model/ --vintage cgmes2    # forced; a mismatch is CIM0021 and exits 1

# Compute a change set, then apply it to the model it was computed against.
cim diff before/ after/ --out change_DIFF.xml
cim apply before/ --change change_DIFF.xml --out updated/

# Typed RDF for a SHACL engine or a triple store.
cim rdf model/ --out graphs/ --ntriples

Output streams#

  • cim diff without --out writes the document alone to stdout and the summary to stderr, so cim diff a b > change_DIFF.xml yields a file. With --out, the summary goes to stdout.
  • cim rdf writes the paths it wrote to stdout and the profiles it skipped for lack of data to stderr.
  • A closed pipe (cim info big-model/ | head) ends the command cleanly.