Tutorial
This section will show a basic way of using Sysand CLI to manage SysML v2 projects. More detailed guides are coming soon.
Initialize a new project using Sysand CLI¶
A model interchange project is a collection of SysML v2 (.sysml) or KerML (.kerml)
files with additional metadata such as project name, versions, and the list of
projects on which it depends. To create a new project called my_project run
$ sysand init my_project
Creating interchange project `my_project`This command will create a new directory (my_project) and populate it with
a minimal interchange project, consisting of two files: .project.json and
.meta.json. To instead create a new project in the current directory, omit
the path (my_project in this case). In that case, the project’s name will
be the same as the current directory name.
Inspect the project¶
Sysand can show some information about the project that was just created with the following commands:
$ cd my_project
$ sysand info
Name: my_project
Version: 0.0.1
No usages.$ sysand sources
*NO OUTPUT*Currently, the project has no usages (dependencies) and no source files of its own.
Add source files¶
For a project to be useful, it needs to have some .sysml/.kerml files of its
own. Create a MyProject.sysml file with the following contents:
package MyProject;Now, you can add MyProject.sysml to the project by running the following command:
$ sysand include MyProject.sysml
Including file: `MyProject.sysml`The source file is now a part of the project, which sysand sources can confirm:
$ sysand sources
/path/to/my_project/MyProject.sysmlAdd usages (dependencies)¶
KerML (and by extension SysML v2) specification calls a project dependency a “usage”. All SysML v2 projects will have at least one dependency on the SysML v2 standard library itself, and many will have dependencies on more SysML v2 projects. The key benefit of Sysand is that it can automatically manage project dependencies for you.
Each usage is identified by an Internationalized Resource Identifier
(IRI) with an optional version constraint. To add dependencies, use the sysand add command. The simplest way to use it is to give an IRI to a package you want
to install from the Sysand Package Index. You can find the IRI (and the full
install command) in the card of the package on the index. It is also possible
to install packages from the URL that points to the .kpar file or to a directory
that contains the project.
Install usage DETECT from Sysand Package Index:
sysand add sensmetry/detectThis may take a few seconds to run, as Sysand needs to download the project
(and its usages as well) into a new local environment. Once finished, a file
sysand-lock.toml and a directory .sysand will be created. The former
records the precise versions of the external projects installed, so that the
same installation can be reproduced later. The latter directory stores the added
project and its usages.
$ sysand info
Name: my_project
Publisher: untitled
Version: 0.0.1
Usages:
pkg:sysand/sensmetry/detectRunning sysand sources again will list all the .sysml files from both the
current project and its (transitive) dependencies.
$ sysand sources
warning: SysML v2/KerML standard library packages are omitted by default.
If you want to include them, pass `--include-std` flag
/path/to/my_project/MyProject.sysml
/path/to/my_project/.sysand/lib/sensmetry-detect_1.3.0/detect_definitions.sysml
/path/to/my_project/.sysand/lib/sensmetry-detect_1.3.0/detect_input.sysml
/path/to/my_project/.sysand/lib/sensmetry-detect_1.3.0/detect_requirement_list.sysml
/path/to/my_project/.sysand/lib/sensmetry-detect_1.3.0/detect_criteria_list.sysml
/path/to/my_project/.sysand/lib/sensmetry-detect_1.3.0/detect_use_cases.sysmlList installed dependencies¶
When we executed sysand add in the previous subsection, it implicitly created
and synchronized an environment for us. For users familiar with Python, Sysand
environments serve the same purpose as Python virtual environments: they store
dependencies needed for a specific project.
We can see everything installed in the local environment using sysand env list:
$ sysand env list
`pkg:sysand/sensmetry/detect` 1.3.0If you want to recreate (the required part of) the environment on a new machine,
make sure you have not only your project files, but also sysand-lock.toml and
execute the following command:
$ sysand sync
Creating env
Syncing env
Installing `pkg:sysand/sensmetry/detect` 1.3.0Package the project¶
After the project reaches some maturity level, there might be a need to package
it to a .kpar file for sharing with others (either through the Sysand Package
Index or otherwise). The .kpar file can be built by running:
$ sysand build
Building kpar `/path/to/my_project/output/my_project-0.0.1.kpar`
$ ls output/
my_project-0.0.1.kparSysand CLI creates a new directory output and puts the generated .kpar file
there. The created .kpar file can then be installed or added as a usage for
another project:
$ sysand init my_other_project
...
$ cd my_other_project/
$ sysand add file:///path/to/my_project/output/my_project-0.0.1.kpar
...