Skip to content

Commit 655fc3a

Browse files
committed
README
1 parent dbc2b1e commit 655fc3a

File tree

1 file changed

+17
-26
lines changed

1 file changed

+17
-26
lines changed

README.md

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -129,70 +129,61 @@ json2models -m Car car_*.json -f attrs > car.py
129129
```
130130

131131
Arguments:
132-
* `-h`, `--help`
133-
* Show help message and exit
132+
* `-h`, `--help` - Show help message and exit
134133

135-
* `-m`, `--model`
134+
* `-m`, `--model` - Model name and its JSON data as path or unix-like path pattern. `*`, `**` or `?` patterns symbols are supported.
136135
* **Format**: `-m <Model name> [<JSON files> ...]`
137-
* **Description**: Model name and its JSON data as path or unix-like path pattern. `*`, `**` or `?` patterns symbols are supported.
138136
* **Example**: `-m Car audi.json reno.json` or `-m Car audi.json -m Car reno.json` (results will be the same)
139137

140-
* `-l`, `--list`
138+
* `-l`, `--list` - Like `-m` but given json file should contain list of model data (dataset).
139+
If this file contains dict with nested list than you can pass `<JSON key>` to lookup.
140+
Deep lookups are supported by dot-separated path. If no lookup needed pass `-` as `<JSON key>`.
141141
* **Format**: `-l <Model name> <JSON key> <JSON file>`
142-
* **Description**: Like `-m` but given json file should contain list of model data (dataset).
143-
If this file contains dict with nested list than you can pass `<JSON key>` to lookup.
144-
Deep lookups are supported by dot-separated path. If no lookup needed pass `-` as `<JSON key>`.
145142
* **Example**: `-l Car - cars.json -l Person fetch_results.items.persons result.json`
146143
* **Note**: Models names under this arguments should be unique.
147144

148-
* `-f`, `--framework`
149-
* **Format**: `-f {base,attrs,dataclasses,custom}`
150-
* **Description**: Model framework for which python code is generated.
145+
* `-f`, `--framework` - Model framework for which python code is generated.
151146
`base` (default) mean no framework so code will be generated without any decorators and additional meta-data.
147+
* **Format**: `-f {base,attrs,dataclasses,custom}`
152148
* **Example**: `-f attrs`
153149
* **Default**: `-f base`
154150

155-
* `--datetime`
156-
* **Description**: Enable datetime/date/time strings parsing.
151+
* `--datetime` - Enable datetime/date/time strings parsing.
157152
* **Default**: disabled
158153
* **Warning**: This can lead to 6-7 times slowdown on large datasets. Be sure that you really need this option.
159154

160-
* `--merge`
155+
* `--merge` - Merge policy settings. Possible values are:
161156
* **Format**: `--merge MERGE_POLICY [MERGE_POLICY ...]`
162-
* **Description**: Merge policy settings. Possible values are:
157+
* **Possible values** (MERGE_POLICY):
163158
* `percent[_<percent>]` - two models had a certain percentage of matched field names.
164159
Custom value could be i.e. `percent_95`.
165160
* `number[_<number>]` - two models had a certain number of matched field names.
166161
* `exact` - two models should have exact same field names to merge.
167162
* **Example**: `--merge percent_95 number_20` - merge if 95% of fields are matched or 20 of fields are matched
168163
* **Default**: `--merge percent_70 number_10`
169164

170-
* `--dict-keys-regex`, `--dkr`
165+
* `--dict-keys-regex`, `--dkr` - List of regular expressions (Python syntax).
171166
* **Format**: `--dkr RegEx [RegEx ...]`
172-
* **Description**: List of regular expressions (Python syntax).
173167
If all keys of some dict are match one of them then this dict will be marked as dict field but not nested model.
174168
* **Example**: `--dkr node_\d+ \d+_\d+_\d+`
175169
* **Note**: `^` and `$` (string borders) tokens will be added automatically but you have escape to other special characters manually.
176170
* **Optional**
177171

178-
* `--dict-keys-fields`, `--dkf`
172+
* `--dict-keys-fields`, `--dkf` - List of model fields names that will be marked as dict fields
179173
* **Format**: `--dkf FIELD_NAME [FIELD_NAME ...]`
180-
* **Description**: List of model fields names that will be marked as dict fields
181174
* **Example**: `--dkf "dict_data" "mapping"`
182175
* **Optional**
183176

184-
* `--code-generator`
177+
* `--code-generator` - Absolute import path to `GenericModelCodeGenerator` subclass.
185178
* **Format**: `--code-generator CODE_GENERATOR`
186-
* **Description**: Absolute import path to GenericModelCodeGenerator subclass.
187179
* **Example**: `-f mypackage.mymodule.DjangoModelsGenerator`
188180
* **Note**: Is ignored without `-f custom` but is required with it.
189181

190-
* `--code-generator-kwargs`
182+
* `--code-generator-kwargs` - List of GenericModelCodeGenerator subclass arguments (for `__init__` method,
183+
see docs of specific subclass).
184+
Each argument should be in following format: `argument_name=value` or `"argument_name=value with space"`.
185+
Boolean values should be passed in JS style: `true` or `false`
191186
* **Format**: `--code-generator-kwargs [NAME=VALUE [NAME=VALUE ...]]`
192-
* **Description**: List of GenericModelCodeGenerator subclass arguments (for `__init__` method,
193-
see docs of specific subclass).
194-
Each argument should be in following format: `argument_name=value` or `"argument_name=value with space"`.
195-
Boolean values should be passed in JS style: `true` or `false`
196187
* **Example**: `--code-generator-kwargs kwarg1=true kwarg2=10 "kwarg3=It is string with spaces"`
197188
* **Optional**
198189

0 commit comments

Comments
 (0)