bogdandm / json2python-models

Generate Python model classes (pydantic, attrs, dataclasses) based on JSON datasets with typing module support
https://pypi.org/project/json2python-models/
MIT License
176 stars 14 forks source link

TODO: Migrate CLI to Typer #47

Open bogdandm opened 2 years ago

bogdandm commented 2 years ago

Current CLI class has a lot of boiler plate code and based on obsolete ArgParser. So it would be easeir to maintain it if it will be rewritten to some modern lib like Typer

ialarmedalien commented 2 years ago

I have used a number of projects recently that use click for cli interaction (click is the only dependency of typer). I had a look at converting json2python-models over to using click, and it looks like the way in which some CLI arguments are specified would have to be changed, at least if you want to be able to include help text with the arguments. Example here. Any input parameter that currently has a variable number of possible values (e.g. -dkf, -dkr, --merge) would need to be changed to only allowing a single value BUT allowing the parameter to be repeated numerous times, i.e.

json2models --merge percent_50 number_500 -m Whatever whatever.json

would need to become

json2models --merge percent_50 --merge number_500 -m Whatever whatever.json

Apart from that, the conversion does not look too hard.