You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43-1Lines changed: 43 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,14 +71,56 @@ Ideally it'd be easier to disable running doc-test on a per-module basis. Placin
71
71
which doesn't run doc-comments is a safer choice, although doc-tests being opt-in would be significantly safer.
72
72
73
73
## Usage
74
-
Generate types from a `.proto` into an project.
75
74
76
75
### Install
77
76
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).
78
77
```
79
78
cargo install --locked proto-gen
80
79
```
81
80
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
+
82
124
### Examples in this project
83
125
This will generate Rust code from the proto specified in `examples/example-project/proto/my-proto.proto` and place it
0 commit comments