Package sdml-cli
This package is part of the Rust SDML project and specifically implements the
sdml
command-line interface (CLI). The project's intent is to provide an
idiomatic implementation of the in-memory model, parser, generators, and the CLI
tool.
The following figure demonstrates this package in the broader project context.
Installation
To install the command-line tool on MacOS or Linux use the Homebrew package manager and the SDML Tap. Installing in this way also installs dependencies such as GraphViz and PlantUML used for diagram generation.
You can check that you have the tool installed and on the path with the following check.
Install via cargo
Cargo is usually installed with the Rust toolchain using rustup.
The following command should download and build the tool, and will also work to install any updates.
Cargo will sometimes report that you have the latest version installed, to be
sure you can force it to install regardless with the --force
option.
Install from source
To install the CLI from source you need to clone the entire repository.
In the rust-sdml
directory you can build/test/install using the following
commands.
Global Options
Certain command-line options act on all commands, these must appear before the
command. The SDML tool has a log-filter
and a no-color
global option.
The set of packages making up rust-sdml
all have extensive logging which can be
enabled when running the tool. The global argument --log-filter
takes a log
level and displays any log event with a severity greater than, or equal to, the
filter.
Some of the commands will, by default, use colored output which can be a problem if you save a file for future processing as the control characters play havoc with diff tools for example.
Commands
Input Files
Getting Help
)
)
)
)
Representation Conversion
This command (convert) allows the conversion of a module from the SDML surface syntax into one of a number of alternate representations.
RDF
This uses the surface to RDF mapping defined in the SDML Language Reference. The mapping is normative and stable.
JSON
This is a direct representation of the in-memory model in the Rust package
sdml_core
in JSON. This mapping is non-normative and may change according to any
model structure change.
S-Expression
This is a debugging representation, and supported as the underlying tree-sitter library uses s-expressions as a parse-tree visualization.
Dependency Visualization
This command (dep) generates a representation of the transitive closure of dependencies for a given module into one of a number of alternate representations.
As Text Tree
Show dependencies as a text tree with the original as the root.
In some cases the entire set of dependencies is not necessary and the --depth
argument can be added to only show a number of levels of import from the root.
The depth argument instructs to command to stop after that many dependencies
away from the original module. Setting depth to 1 will only show the direct
dependencies of the original.
As GraphViz Graph
Create an SVG representation of the dependency graph using GraphViz.
As RDF Statements
Create a set of RDF statements,as N-Triples, that represent the individual OWL import relationships.
<http://sdml.io/sdml-owl.ttl#> <http://www.w3.org/2002/07/owl#imports> <http://www.w3.org/2002/07/owl#> .
<http://sdml.io/sdml-owl.ttl#> <http://www.w3.org/2002/07/owl#imports> <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
<http://sdml.io/sdml-owl.ttl#> <http://www.w3.org/2002/07/owl#imports> <http://www.w3.org/2000/01/rdf-schema#> .
<http://sdml.io/sdml-owl.ttl#> <http://www.w3.org/2002/07/owl#imports> <http://www.w3.org/2004/02/skos/core#> .
<http://sdml.io/sdml-owl.ttl#> <http://www.w3.org/2002/07/owl#imports> <http://www.w3.org/2001/XMLSchema#> .
Diagram Generation
This command (draw) generates diagrams of a module with different perspectives.
Concept Diagram
Entity Relationship Diagram
UML Class Diagram
Document (Project) Generation
This command (doc-book) creates structured documentation for a collection of modules, and includes annotations, constraints and all definition types. The generated documentation also include diagrams and dependency graphs.
In Org-mode
Create an Emacs org-mode formatted file. This format allows all content to be written into a single file with export options to HTML, LaTeX, Word, PDF and more.
Document (Module) Generation
This command (doc) creates structured documentation for a module, and includes annotations, constraints and all definition types. The generated documentation also include diagrams and dependency graphs.
In Org-mode
Create an Emacs org-mode formatted file. This format allows all content to be written into a single file with export options to HTML, LaTeX, Word, PDF and more.
In Markdown
Create a markdown formatted file, this file uses GitHub-flavored markdown to allow for some better content formatting than CommonMark.
Module Highlighting
TBD
XRef Tag Generation
TBD
Validation
This command (validate) provides deep validation of a module's content, including errors, warnings, and linter-like advice. Checks are run not only on the initial module, but it's transitively loaded dependencies.
= )
=
= )
=
Additionally, a short-form
option will generate diagnostics using a CSV format
that is easier for tools to parse. The fields in this format are: severity, file
name, start line, start column, end line, end column, error code, and message.
Version Information
This command (versions) shows more information than the simple --version
global
argument and is useful for debugging.
Module Viewer
This command (view) will generate source code from a module file, which at first
seems redundant. However, this view provides levels of detail that allow for an
overview of module definitions. The --level
argument can be used to elide
content and get an overview of a module.
Definitions Only
Show only the definitions in the module, any definition body will be elided, for
an overview of the module contents. Elided definitions are followed by ";; ..."
.
;
;;
;
Members
Show definitions in the module and show the members of product types and variants of sum types but not their bodies if present.
;
;;
;
Full
Show all contents of the module.
Changes
Version 0.3.2
- Style: Changed cargo file to use license key instead of license-file.
Version 0.3.1
- Feature: added new
generate
command which uses thesdml-tera
package for template-driven generators.
Version 0.3.0
- Feature: updates to support the latest grammar, see
sdml-core
. - Refactor: use the latest ~
Generator~
trait.
Version 0.2.10
- Feature: added new command
doc-book
to create a more complex documentation output for a collection of modules. - Build: bump version of
sdml-errors
,sdml-core
, andsdml-generate
.
Version 0.2.9
- Build: update dependency from
sdml_error
tosdml-errors
. - Build: bump versions of
sdml-core
,sdml-parse
,sdml-generate
.
Version 0.2.8
- Build: upgrade to
sdml_core
version0.2.14
and the newModelStore
trait.
Version 0.2.7
- Feature: better error handling in conjunction with the validation and
diagnostics in
sdml-errors
.
Version 0.2.6
- Build: update dependencies.
Version 0.2.5
- Feature: Add new
--no-color
flag to the CLI which also uses theNO_COLOR
environment variable. - Feature: Removed indirect dependencies from
Cargo.toml
. - Update: New generator features for colored RDF.
Version 0.2.4
- Feature: Add new
source
command to call the new source generator. - Fix: Change the description of
depth
parameter fordeps
command, 0 is the default which means all depths are included in the output. - Update: Use new generator traits that require a module cache parameter.
Version 0.2.3
- Feature: add new
stdlib
modules with standard layout. - Feature: minor refactor of cache and loader.
Version 0.2.2
- Feature: Update to latest grammar for version URIs and RDF definitions.
- Add support for base URI on modules.
- Add support for version info and URI on modules.
- Add support for version URI on module import.
- Parse RDF definitions for classes and properties.
Version 0.2.1
- Feature: Remove member groups.
Version 0.2.0
- Feature: Update to latest grammar.
- Remove
ValueVariant
numeric values. - Update formal constraints.
- Add type classes.
- Remove
Version 0.1.6
- Updated dependencies.
Version 0.1.5
Initial stand-alone crate.
Version 0.1.4
Previously part of a single crate sdml.