# CLI Utilities

### protocol-code-generator

This tool has built in help that you can access like this:

`protocol-code-generator --help`&#x20;

If you want information about a special command, instead do:

`protocol-code-generator --help generate`&#x20;

| Flags                 |                                                           |
| --------------------- | --------------------------------------------------------- |
| `-d, --schema=STRING` | The schema file (.schema)                                 |
| `-o, --output=STRING` | Output file                                               |
| `--output-dir=STRING` | Output directory (can only be used together with --split) |
| `-c, --code=STRING`   |                                                           |
| `-e, --ecs=STRING`    |                                                           |
| `--sync=STRING`       |                                                           |

When running the schema generator, it needs to know the location of the schema file and what kind of code it should generate.&#x20;

It will emit the generated code to `stdout`, so you have to [pipe ](https://en.wikipedia.org/wiki/Pipeline_\(Unix\))that to a text file in order to save it (for example using the `>` operator). Here's an example of how it can look:

&#x20;`protocol-code-generator generate --code csharp --ecs unity --schema ./coherence.schema > ./generated/schema.cs`&#x20;

The emitted file should be placed somewhere inside your Unity project.

###

### replication-server

The replication server also has general and specific help.

`replication-server --help`&#x20;

`replication-server --help serve`&#x20;

| Flags                        |                                                   |
| ---------------------------- | ------------------------------------------------- |
| `--port=32001`               | The port to listen to                             |
| `--stats-port=32000`         | The port to listen for stats scrapers             |
| `--dump`                     | Write network packets to capture files (.packets) |
| `--frequency=20`             | The server update frequency                       |
| `--schema=STRING`            | The schema file (.schema)                         |
| `--entities=STRING`          | Entity snapshot (.yaml)                           |
| `--parent-replicator=STRING` | Host address for parent replicator connection     |
| `--use-world-partitioner`    | If set, the binary\_partitioner is used           |
| `--disconnect-timeout=5000`  | Disconnect timeout (in milliseconds)              |
| `--debug-streams`            | Use debug streams                                 |
| `--max-entities=65536`       | Maximum number of entities allowed                |
| `--min-query-distance=0.1`   | Minimum distance for query change                 |

To start the server, you need to give it the location of the schema, like this:

`replication-server serve --schema ../Assets/coherence/coherence.schema`

In the example above we're running the server from the `coherence-bin` directory right at the root of your project.

You can also define other parameters like `min-query-distance` (the minimum distance the LiveQuery needs to move for the replicator to recognize a change), `frequency`, `ip` and `port` number.

`replication-server serve --min-query-distance 10 --port 32001 --frequency 320 --schema "C:\Users\tadej\Desktop\work\coherence\gamejam-stellar\Assets\Schemas\stellar.schema"`

### simulation-server

You can run coherence simulation server using&#x20;

`./sim_x86_64 --coherence-simulation-server` &#x20;

### persistence-client

The persistence client has general and specific help.

`persistence-client serve --help`&#x20;

`persistence-client --help serve`

| Flags                             |                                                             |
| --------------------------------- | ----------------------------------------------------------- |
| `--save-file-name="world.save" .` | The name of the persistent save file                        |
| `--save-folder="."`               | The folder where the save file is written                   |
| `--save-frequency=30`             | The frequency in which the save file is written, in seconds |
| `--host="127.0.0.1:32001"`        | The host:port to connect to                                 |
| `--dump`                          | Write network packets to capture files (.packets)           |
| `--frequency=20`                  | The server update frequency                                 |
| `--schema=STRING`                 | The schema file (.schema)                                   |
| `--disconnect-timeout=5000`       | Disconnect timeout (in milliseconds)                        |
| `--debug-streams`                 | Use debug streams                                           |
| `--query-world-position="0,0,0"`  | Position of the center of the entity query                  |
| `--query-radius=10000`            | Radius of entity query                                      |

### General flags

|                                |                               |
| ------------------------------ | ----------------------------- |
| `--log-level=LOG-LEVEL-STRING` | Log level                     |
| `--log-file=LOG-FILE-STRING`   | Log output file               |
| `--panic-on-error`             | Enable/disable panic on error |
