# CLI Utilities

Found in `<package-root>/.Runtime/<platform>/`.

### protocol-code-generator

`protocol-code-generator --help`

`protocol-code-generator --help generate`

```
      --log-level=LOG-LEVEL-STRING
                             the log level
      --log-file=LOG-FILE-STRING
                             log output file
      --panic-on-error       enable/disable panic on error

  -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          Which language to generate code for.
  -e, --ecs=STRING           Which flavour of ECS to generate code for.
      --split                Split into files.
      --debugoutput          Insert debug output in generated code.
      --sync=STRING          Path to Unity generated JSON file for creating the
                             generated.schema file.
      --emit-empty           Emit empty baked scripts. Useful to avoid possible
                             compile errors. 
```

### replication-server

`replication-server --help serve`

```
Usage: replication-server serve --schema=STRING

Flags:
  -h, --help                                        Show context-sensitive help.
      --log-level=LOG-LEVEL-STRING                  the log level
      --log-file=LOG-FILE-STRING                    log output file
      --panic-on-error                              enable/disable panic on error

      --port=32001                                  The port to listen to.
      --stats-port=32000                            The port to listen for stats scrapers. Also enables pprof.
      --use-p-prof                                  If StatsPort is 0 then setup pprof on port 6060.
      --dump                                        Write network packets to capture files (.packets).
      --dump-reverse                                Write network packets reversing in and out 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.
      --max-entities=65536                          Maximum number of entities allowed.
      --max-clients=200                             Expected maximum number of clients.
      --min-query-distance=0.1                      Minimum distance for query change.
      --web-support                                 Does this support web connections.
      --public-ip=STRING                            Public IP of the replication server, used by webrtc.
      --web-port=32003                              Port for webrtc, only used if --web-support is true
      --signalling-port=32002                       Port for signalling, only used if --web-support is true
      --out-stats-freq=1                            Frequency, in seconds, of updates to prometheus stats
      --log-stats-freq=0                            Frequency, in seconds, of output of stats to INFO logs. 0 - no output
      --env="prod"                                  Environment in which the server is executed
      --persistence-enabled                         If enabled, starts replication server with persistence attached.
      --persistence-save-file-name="world.save"     The name of the persistent save file.
      --persistence-save-folder="."                 The folder where the save file is written.
      --persistence-save-frequency=30               The frequency in which the save file is written (in seconds).
      --persistence-query-world-position="0,0,0"    Position of the center of the entity query.
      --persistence-query-radius=10000              Radius of entity query.
      --persistence-disable-s-3-storage             Enable to disable storing to S3.
      --persistence-upload-size-threshold=1024      Difference in bytes to cause an s3 upload.
      --persistence-upload-frequency-forced=3600    The maximum number of seconds between forced s3 uploads.
```

`replication-server --help listen`

```
  -h, --help                          Show context-sensitive help.
      --log-level=LOG-LEVEL-STRING    the log level
      --log-file=LOG-FILE-STRING      log output file
      --panic-on-error                enable/disable panic on error

      --port=64001                    The port to listen to.
      --default-frequency=20          The default server update frequency.
      --default-schema=STRING         The default schema file (.schema).
      --stats-port=64000              The port to listen for stats scrapers. Also enables pprof
      --use-p-prof                    If StatsPort is 0 then setup pprof on port 6060.
      --udp-port=42001                Port for udp traffic.
      --web-support                   Does this support web connections.
      --web-port=42003                Port for webrtc, only used if --web-support is true
      --public-ip=STRING              Public IP of the replication server, used by webrtc.
      --signalling-port=42002         Port for signalling, only used if --web-support is true
      --disconnect-timeout=5000       Disconnect timeout (in milliseconds).
      --out-stats-freq=1              Frequency, in seconds, of updates to prometheus stats
      --log-stats-freq=0              Frequency, in seconds, of output of stats to INFO logs. 0 - no output
      --env="prod"                    Environment in which the server is executed
      --secret=STRING                 Expected secret in the api requests
      --has-persistence               Does this support enabling persistence.
```

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"`

### persistence-client

`persistence-client --help serve`

```
  -h, --help                            Show context-sensitive help.
      --log-level=LOG-LEVEL-STRING      the log level
      --log-file=LOG-FILE-STRING        log output file
      --panic-on-error                  enable/disable panic on error

      --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.
      --room-id=0                       The room id to connect 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).
      --max-entities=32767              The maximum number of entities saved
      --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.
      --disable-s-3-storage             Enable to disable storing to S3.
      --upload-size-threshold=1024      Difference in bytes to cause an s3 upload.
      --upload-frequency-forced=3600    The maximum number of seconds between forced s3 uploads.
```

### 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 |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coherence.io/0.8/resources/cli-utilities.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
