ssd 0.8.2

A service and data description format + a code generator based on rhai scripts and templates
Documentation

SSD - Simple Service Description

ATTENTION: BREAKING CHANGE!

I changed the syntax from handles to fn and the field from handlers to functions.

Features

  • Custom description language (basics are done, but some things are still missing)
  • Auto format
  • Basic sanity checks
  • Run RHAI scripts to generate output

Future Features

  • Run WASM plugins to generate output

You can check out the file:

Install

cargo install --locked ssd

Usage

General

➜ ssd help
Simple Service Description & Code Generator

Usage: ssd [COMMAND]

Commands:
  debug          Print debug representation of the parsed file
  generate       Generate source code
  rhai-metadata  Print script engine metadata (function definitions, etc.) as json
  help           Print this message or the help of the given subcommand(s)

Options:
  -h, --help  Print help

Generate

➜ ssd generate help
Generate source code

Usage: ssd generate <COMMAND>

Commands:
  rhai        Use a rhai based generator
  handlebars  Use a handlebars based template. https://handlebarsjs.com/
  tera        Use a tera based template. https://tera.netlify.app/
  liquid      Use a liquid based templates. https://shopify.github.io/liquid/
  help        Print this message or the help of the given subcommand(s)

Options:
  -h, --help  Print help

Rhai

➜ ssd generate rhai --help
Use a rhai based generator

Usage: ssd generate rhai [OPTIONS] <SCRIPT> <FILE>

Arguments:
  <SCRIPT>
          The script to use to generate the file

  <FILE>
          which file to use

Options:
  -d, --debug
          Enables debug mode (print and debug function in the script)

      --no-map
          do not use type mappings

      --typemap <TYPEMAP>
          A file containing type mappings.
          
          If a file with the same name as the script file, but with the extension tym, it will be used automatically. e.g.: If there is a file
          `/generator/script.rhai` and a corresponding `/generator/script.tym`, it will get used automatically.

  -o, --out <OUT>
          The file which should get written with the output from the generator

  -h, --help
          Print help information (use `-h` for a summary)

Handlebars

Alias: ssd generate hbs

➜ ssd generate handlebars --help
Use a handlebars based template. https://handlebarsjs.com/

Usage: ssd generate handlebars [OPTIONS] <TEMPLATE> <FILE>

Arguments:
  <TEMPLATE>
          The template to use to generate the file

  <FILE>
          which file to use

Options:
      --no-map
          do not use type mappings

      --typemap <TYPEMAP>
          A file containing type mappings.
          
          If a file with the same name as the script file, but with the extension tym, it will be used automatically. e.g.: If there is a file
          `/generator/script.rhai` and a corresponding `/generator/script.tym`, it will get used automatically.

  -o, --out <OUT>
          The file which should get written with the output from the generator

  -h, --help
          Print help (see a summary with '-h')

Tera

➜ ssd generate tera --help
Use a tera based template. https://tera.netlify.app/

Usage: ssd generate tera [OPTIONS] <TEMPLATE_DIR> <TEMPLATE_NAME> <FILE>

Arguments:
  <TEMPLATE_DIR>   Glob path for where to search for templates
  <TEMPLATE_NAME>  The template to use to generate the file
  <FILE>           which file to use

Options:
      --typemap <TYPEMAP>  A file containing type mappings
  -o, --out <OUT>          The file which should get written with the output from the generator
  -h, --help               Print help

Liquid

Alias: ssd generate lqd

➜ ssd generate liquid --help
Use a liquid based templates. https://shopify.github.io/liquid/

Usage: ssd generate liquid [OPTIONS] <TEMPLATE> <FILE>

Arguments:
  <TEMPLATE>
          The template to use to generate the file

  <FILE>
          which file to use

Options:
      --no-map
          do not use type mappings

      --typemap <TYPEMAP>
          A file containing type mappings.
          
          If a file with the same name as the script file, but with the extension tym, it will be used automatically. e.g.: If there is a file
          `/generator/script.rhai` and a corresponding `/generator/script.tym`, it will get used automatically.

  -o, --out <OUT>
          The file which should get written with the output from the generator

  -h, --help
          Print help (see a summary with '-h')

To test it out you can use the following command:

ssd generate rhai generators/cpp-like.rhai data/test.svc