# Librarian CLI

## Introduction

The Librarian command-line interface (CLI) is built in typescript. It takes different VPAT versions (508, WCAG, WCAG21508, EU, INT) as an option and generates the corresponding catalogs. The script uses hardcoded logic to build the combined catalogs so any adjustments will have to be done in the script to change the order or anything of the combined catalogs.

**Note**: The catalogs in the 'catalog' directory are auto-generated using the librarian utility. To change the text in the catalog first edit their values in the data directory and then regenerate the combined catalog.

## Install

Install the dependencies with the following NPM command:

```bash
npm install
```

## Source

Main application code is in the `src` directory.

## Commands and examples

The Librarian CLI can be executed without compiling using [`ts-node`](https://typestrong.org/ts-node/). Currently, the CLI is only used to create the catalogs whenever they change and not a regular process.

### Help

Use `--help` to reveal the CLI instructions.

```bash
> npx ts-node src/librarian.ts --help
Options:
      --help     Show help                                             [boolean]
      --version  Show version number                                   [boolean]
  -c, --catalog  Select which VPAT 2.4 catalog to rebuild: WCAG, 508, WCAG21508,
                 EU, INT                                     [string] [required]
```

### Examples

You can run the CLI with the following example commands:

```bash
# Generates 508 catalog example.
> npm run generate-508-catalog # Full command `npx ts-node src/librarian.ts -c 508`
Warning: This will rebuild the following catalog: 508.
Successfully created catalog ./catalog/2.4-edition-wcag-2.0-508-en.yaml.
```

## Data for the catalogs generation

The catalogs are generated by combining different ones from `catalog/data` directory. For example running the command with '508' will take `wcag-2.0.yaml`, `508.yaml`, `terms.yaml`, and `components.yaml` to create `2.4-edition-wcag-2.0-508-en.yaml`. Other commands will do something similar as well.

- `508.yaml`: VPAT® 2.4 Revised Section 508 Edition.
- `wcag-2.0.yaml`: WCAG 2.0.
- `wcag-2.1.yaml`: WCAG 2.1.
- `terms.yaml`: Contains definitions of "supports", "partially-supports", and so on.
- `components.yaml`: Contains definitions of "Web", "Electronic Documents", and so on.

All data catalogs are validated against the same schema (`openacr-catalog-0.1.0.json`) as the combined catalog when running the librarian command.
