Skip to content

Commit d9f1b51

Browse files
authored
Add command-line options to usage in readme
1 parent 08f551f commit d9f1b51

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

README.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,56 @@ Ideally it'd be easier to disable running doc-test on a per-module basis. Placin
7171
which doesn't run doc-comments is a safer choice, although doc-tests being opt-in would be significantly safer.
7272

7373
## Usage
74-
Generate types from a `.proto` into an project.
7574

7675
### Install
7776
To install `proto-gen` from source do the following. This assumed you have installed a recent [rust toolchain](https://www.rust-lang.org/tools/install).
7877
```
7978
cargo install --locked proto-gen
8079
```
8180

81+
### Command-line options
82+
83+
Usage:
84+
85+
```
86+
proto-gen [OPTIONS] <COMMAND>
87+
```
88+
89+
#### Commands:
90+
91+
The top-level commands are:
92+
93+
- `validate` Generate new Rust code for proto files, checking current files for differences. Returns error code 1 on any found differences.
94+
- `generate` Generate new Rust code for proto files, overwriting old files if present.
95+
- `help` Print this message or the help of the given subcommand(s).
96+
97+
`validate` & `generate` share the following sub-options:
98+
99+
- `-d`, `--proto-dirs` `<PROTO_DIRS>` Directories containing proto files to source (Ex. Dependencies), needs to include any directory containing files to be included in generation.
100+
- `-f`, `--proto-files` `<PROTO_FILES>` The files to be included in generation.
101+
- `-t`, `--tmp-dir` `<TMP_DIR>` Temporary working directory, if left blank, `tempfile` is used to create a temporary directory.
102+
- `-o`, `--output-dir` `<OUTPUT_DIR>` Where to place output files. Will get cleaned up (all contents deleted). A module file will be placed in the parent of this directory.
103+
- `-h`, `--help` Print help.
104+
105+
#### Options:
106+
The top-level options are:
107+
108+
- `-s`, `--build-server` Whether to build server code.
109+
- `-c`, `--build-client` Whether to build client code.
110+
- `--generate-transport` Whether to generate the `::connect` and similar functions for tonic.
111+
- `-d`, `--disable-comments` `<DISABLE_COMMENTS>` Disable comments based on proto path. Passing `'.'` disables all comments.
112+
- `-b`, `--btree-map` `<BTREE_MAPS>` Output maps as `BTreeMap` instead of `HashMap`. Passing `'.'` makes all maps `BTreeMap`.
113+
- `--type-attribute` `<TYPE_ATTRIBUTES>` Type attributes to add.
114+
- `--enum-attribute` `<ENUM_ATTRIBUTES>` Enum attributes to add.
115+
- `--client-attribute` `<CLIENT_ATTRIBUTES>` Client mod attributes to add.
116+
- `--server-attribute` `<SERVER_ATTRIBUTES>` Server mod attributes to add.
117+
- `-f`, `--format` Use `rustfmt` on the code after generation, `rustfmt` needs to be on the path.
118+
- `-p`, `--prepend-header` Prepend header indicating tool version in generated source files.
119+
- `--prepend-header-file` `<PREPEND_HEADER_FILE>` Prepend header file in generated source files.
120+
- `--toplevel-attribute` `<TOPLEVEL_ATTRIBUTE>` Toplevel mod attribute to add.
121+
- `-h`, `--help` Print help.
122+
- `-V`, `--version` Print version.
123+
82124
### Examples in this project
83125
This will generate Rust code from the proto specified in `examples/example-project/proto/my-proto.proto` and place it
84126
in `examples/example-project/src/proto_types`.

0 commit comments

Comments
 (0)