tonto-cli
TypeScript icon, indicating that this package has built-in type declarations

0.3.6 • Public • Published

Logo

An DSL for Ontology models

 

Tonto CLI

Tonto Command Line Interface (CLI) is a tool that expands the use of Tonto models by enabling the transformation of Tonto projects into other formats and providing validation capabilities.

Functionalities

  1. Transformation to JSON: The generate command converts a Tonto model into a JSON file that adheres to the OntoUML JSON schema. This allows for interoperability with OntoUML tools and further processing.
    tonto-cli generate [directoryName]
  2. Import from JSON: The import command takes a JSON file conforming to the OntoUML JSON schema and generates a corresponding Tonto project. This facilitates the migration of existing OntoUML models to Tonto.
    tonto-cli import [jsonFileName]
  3. Transformation to OWL: The transform command converts a Tonto model into a gUFO-based OWL ontology using the Turtle syntax. This bridges the gap between conceptual models and formal ontologies used in the Semantic Web.
    tonto-cli transform [directoryName]
  4. Validation: The validate command sends the Tonto model to the ontouml-server API for validation. It returns any validation errors identified by the server, helping to ensure the model's correctness and adherence to OntoUML/UFO rules.
    tonto-cli validate [directoryName]

Installation and Usage

Tonto CLI is available as an NPM package. To install it globally, use the following command:

npm install -g tonto-cli

Once installed, you can use the tonto-cli command followed by the desired command and directory or file name to perform the corresponding action.

Additional Considerations

  • Node.js Requirement: Tonto CLI requires Node.js to be installed on your system.
  • Global Installation: Installing Tonto CLI globally allows you to use the tonto-cli command from any directory.

Language Elements

Tonto grammar allows you declare elements by using its keyword and the defined name for the element.

package example 

kind Person {
    name: String
    age: Integer
    gender: Gender
}

phase Child specializes Person

enum Gender {
    MALE
    FEMALE
    OTHER
}

relation Person [0..*] -- hasFriend -- [0..*] Person

Package Declarations

Tonto specifications are organized into packages, defined using the package keyword followed by the package name. Packages act as namespaces and are fundamental for modularity.

package myPackage

Class Declarations

Classes are declared using keywords corresponding to UFO types (e.g., kind, role, phase) followed by the class name. Specializations are indicated using the specializes keyword.

kind Person {
    name: string
    birthDate: date {const}
}

phase Child specializes Person

Datatype Declarations

Tonto supports built-in datatypes (number, string, boolean, date, time, datetime) and allows defining custom datatypes using the datatype keyword.

datatype Address {
    street: string
    number: int
}

Enumeration Declarations

Enumerations are declared using the enum keyword, listing possible literal values.

enum EyeColor { Blue, Green, Brown, Black }

Generalization Sets

Generalization sets define relationships between a general class and its specializations. They can be marked as disjoint and/or complete.

disjoint complete genset PersonAgeGroup where Child, Adult specializes Person

genset PersonAgeGroup {
    general Person
    specifics Child, Adult
}

Relations

Relations (associations) can be declared internally (within a class body) or externally. They are specified using relation stereotypes (e.g., @componentOf, @mediation) and cardinalities.

// Internal relation
kind University {
    @componentOf [1] <>-- [1..*] Department
}

// External relation
@mediation relation EmploymentContract [1..*] -- [1] Employee

⌨️ Getting Started

This is the instructions on setting up your project locally. To get a local copy up and running follow these simple example steps:

Prerequisites

This is all the tools you need installed to run the project and the versions that are preferred

  • nodejs - v16.9.1 or higher
  • npm - 7.21.1 or higher
  • Yarn - 1.22.18 (not mandatory, but recommended)

⚙️ Initializing

  • Run npm run langium:generate to generate TypeScript code from the grammar definition.
  • Run npm run build to compile all TypeScript code or npm run watch if you want the compiler to work automatically everytime you update your files
  • Press F5 to open a new window with your extension loaded.
  • Create a new file with a file name suffix matching your language.
  • Verify that syntax highlighting, validation, completion etc. are working as expected.

CLI Commands

  • Help command to list all available commands
   tonto-cli help
  • Generate JSON File from Tonto Project command::
   tonto-cli generate <dirName>
  • Generate Tonto Project from a JSON Filee
   tonto-cli import <fileName.json>
  • Validate Tonto Project with ontouml-js server APII
   tonto-cli validate <dirName>
>

🔐 License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

✉️ Contact

Matheus Lenke Coutinho - matheus.l.coutinho@edu.ufes.br - Linkedin - Github

(back to top)

Readme

Keywords

none

Package Sidebar

Install

npm i tonto-cli

Weekly Downloads

10

Version

0.3.6

License

MIT

Unpacked Size

1.13 MB

Total Files

620

Last publish

Collaborators

  • matheuslenke