# generate

Use `greymatter generate` to generate textual output such as Grey Matter object definitions via templates.

Generate command utilizes a library called [Pathogen](https://github.com/galaho/pathogen). Templates can be stored in a directory or Github repo, and variable resolution will be done via stdin or an input file specified via a flag.

## Usage

```bash
greymatter generate REPOSITORY DESTINATION [flags]
```

### Arguments

#### `REPOSITORY`

A repository can be a Github repo URL (SSH URL, not HTTPS) + folder name (e.g. `git@github.com:greymatter-io/pathogen-greymatter.git//cluster`) or simply a full/relative path to a folder on your machine that contains templates and its configuration (by default, the configuration file name is `.pathogen.yml`, if that is not the case, the name needs to be passed to a flag `--template-config`).

#### `DESTINATION`

A full or relative path to a folder (if it does not exist, it will be created) to store the output.

### Flags

* `--input`: a file for non-interactive variable resolution
* `--template-config`: a config file for templating such as variables, defaults, and other settings (a default file name is  `.pathogen.yml`)

### Sample Usage

#### Usage 1: Interactive & Github + Relative Path

Using a template stored in a Github repository, generate and store the output in `./cluster-output` folder. For each variable in a template, a user will be asked what the value should be.

```bash
greymatter generate git@github.com:greymatter-io/pathogen-greymatter.git//cluster cluster-output
```

#### Usage 2: Non-interactive & Relative path + Absolute Path

Using a template in a local folder `./example`, generate and store the output in `/tmp/output` folder. Input is read in from the `input.yaml` file. The variable resolution is done via `input.yaml` file.

```bash
greymatter generate example /tmp/output --input=input.yaml
```

> For more information about what the contents of input.yaml file looks like, please refer to [Pathogen example](https://github.com/galaho/pathogen/tree/master/example).

#### Usage 3: Non-interactive & Absolute path + Relative Path

Using a template in a local folder /Users/me/example, generate and store the output in `./yaml` folder. Input is resolved using what is in the `input.txt` file. The variable resolution is done via `input.txt` file which contains all the inputs you would have typed in the usage 1 above. The difference between usage 2 input and this one is that the one for usage 2 will have the template variable names as the keys of the yaml file, so it is easier to read compared to input.txt file that only lists values separated by a newline character.

```bash
cat input.txt | greymatter generate /Users/name/example yaml
```
