MRG Import Tool
The MRG Import Tool (MRG importer) ensures that the scope within which it is run, obtains a local copy of all MRGs that are available in the scopes that are mentioned in the scopes
section of its SAF. This makes life easy for various tools, e.g., the MRGT and the TRRT, that can now assume that all MRGs that they may need to consult in order to do their job, are readily available.
Installing the Tool
The tool can be installed from the command line and made globally available by executing
npm install -g @tno-terminology-design/mrg-import
Before running the tool from the command line, make sure you have met the necessary prerequisites depending on your operating environment.
- CMD.exe (Windows)
- PowerShell(Windows)
- Bash (Linux/Mac)
- Node.js and NPM: Ensure Node.js and NPM are installed.
- Global Installation: If you have installed the package globally, confirm the global NPM modules path by running
npm config get prefix
. The global modules are usually stored under<prefix>/node_modules
. - Environment Variables: Add the path to global NPM binaries to your system's PATH environment variable. This should be
<prefix>
on Windows. To add to PATH, you can edit your environment variables or runset PATH=%PATH%;<prefix>
in the CMD.
- Node.js and NPM: Ensure Node.js and NPM are installed.
- Global Installation: Check the global NPM modules path as in CMD.
- Environment Variables: Update the PATH environment variable as in CMD. You can also use
$env:Path += ";<prefix>"
to update the PATH temporarily in the current PowerShell session.
- Node.js and NPM: Ensure Node.js and NPM are installed.
- Global Installation: If globally installed, run
npm config get prefix
to get the global modules path, usually<prefix>/lib/node_modules
. - Environment Variables: Add the
<prefix>/bin
directory to yourPATH
if it's not already. You can do this by addingexport PATH=$PATH:<prefix>/bin
to your~/.bashrc
or~/.zshrc
file.
Calling the Tool
The behavior of the MRG importer can be configured per call e.g. by a configuration file and/or command-line parameters. The command-line syntax is as follows:
mrg-import [ <paramlist> ]
where <paramlist>
is an (optional) list of parameters.
Legend
The columns in the following table are defined as follows:
Parameter
specifies the parameter and further specificationsReq'd
specifies whether (Y
) or not (n
) the field is required to be present when the tool is being called. If required, it MUST either be present in the configuration file, or as a command-line parameter.Description
specifies the meaning of theValue
field, and other things you may need to know, e.g. why it is needed, a required syntax, etc.
If a configuration file used, the long version of the parameter must be used (without the preceding --
).
Key | Req'd | Description |
---|---|---|
-c , --config <path> | n | Path (including the filename) of the tool's (YAML) configuration file. |
-s , --scopedir <path> | Y | Path of the scope directory from which the tool is called. |
-e , --onNotExist <action> | n | The action in case an MRG file unexpectedly does not exist. |
-V , --version | n | output the version number of the tool. |
-h , --help | n | display help for command. |
`-e`, `--onNotExist` Actions
<action> | Description |
---|---|
'throw' | an error is thrown (an exception is raised), and processing will stop. |
'warn' | a message is displayed (and logged) and processing continues. |
'log' | a message is written to a log(file) and processing continues. |
'ignore' | processing continues as if nothing happened. |
Running the Tool
The current version of the tool simply reads all MRG files from all scopes that are specifeid in the SAF.
It does so by reading the scopes
section of its SAF (of the current scope). This section contains entries, each of which specifies a scopetag
field and a URL
field. We will use <my-stag>
and <url>
to refer to the values of these fields respectively.
For each such entry, the tool obtains the SAF of that scope, which is located at <url>
, and from there, it determines the path of the (remote) glossarydir, as well as the scopetag <stag>
that it uses to refer to itself, and is used as part of the filenames that contain MRGs that are generated within that scope.
Then, it copies all files from the remote glossarydir that are named mrg.<stag>*.yaml
to the glossarydir of the current scope, and replaces the <stag>
part with <my-stag>
(as the scope that calls itself <stag>
is called <my-stag>
in the current scope).
Exceptions, Warnings, and Logging
This section needs to be reviewed/revised so as to enable a consistent way of error checking and logging, similar to what is done in the TRRT
The general principle is that the MRG importer helps its users to do their jobs. This means that errors that terminate the processing are limited to the max, that warnings (perhaps at different 'levels' of detail/severity) are given output whenever possible (yet may be limited by command-line options), and that texts are tailored for the envisaged users of the tool.
Also, the MRGT provides suggestions that help tool-operators (curators) to not only identify, but also fix any problems.