Node CLI for General Language Syntax (GLS).
npm install general-language-syntax gls-cli ts-gls typescript gls-cli --global gls --help
Pass any number of filenames and/or globs (matched with glob) to the CLI to convert those files to an output
Input files to convert from GLS to the output language must have a
.ts files may also be given with
--tsconfig to compile to
.gls files before output language conversion.
||Glob(s) of file(s) to exclude from conversion.|
Output language to convert to.
Namespace before path names, such as
Path to a
TypeScript project configuration file.
||Prints the GLS, GLS-CLI, and TS-GLS versions.|
gls --language Python file.gls
*.gls, then to
gls --language Java --tsconfig ./tsconfig *.ts
Requires Node >=8
To build from scratch, install Node.js and run the following commands:
npm install npm install general-language-syntax ts-gls typescript --no-save npm run verify
package.json for the full list of commands.
To set up source file compiling in watch mode, use
tsc -p test to build tests, or
tsc -p test -w to rebuild the files in watch mode.
npm run test:run to run tests.
When the CLI is called, the following code paths are used in order:
Parses raw string arguments using
If the args are valid, it calls to the
System dependencies such as the
IFileSystem and globber may be dependency-injected to override the defaults.
Validates GLS settings, sets up the conversion's
Postprocess, then runs them in that order.
There are two real behaviors here not covered by the
- Globbing file paths passed as glob args and reading them the file system.
- Validating the provided language is known by GLS.
If any files are passed in with native language extensions, namely
.ts for TypeScript, they are converted here using that langauge's converter to their
For example, if a
.ts file is provided, it will attempt to convert it using TS-GLS and return the generated
.gls file path.
.gls file path is provided, it will do nothing and pass that path through.
Any language-specific files that are used as metadata files for that language, such as
.gls file to the output language(s).
convertFiles uses an async queue to throttle the number of files that are attempted to be converted via
convertFile at once, as some conversions may need asynchronous operations.
GlsConverter per output language and has each file run through them.
Runs tasks on the converted
.gls files as a project group after they've been successfully created.
.gls.json is not provided or detected, this does nothing.
Otherwise, it creates a root metadata file(s) as specified by each output language.
These are typically one or both of:
- Metadata file describing the output project.
- Exports file exporting publicaly exportable objects for languages that need them.