[Enhancement] use Typer and questionary for the CLI
Why
below I created a mock application with typer to illustrate my point of view:
- better information display
- better error display :
- type checking everywhere
- modularity
- shell completion
- all the powerful stuff that
richprovides ( i.e tables, spinners, progress bars,...)
using questionary provides a much more intuitive user experience:
If any of the maintainers finds this interesting, you can assign it to me and I will work on it 🙂
@kareemmahlees Thanks for this 👍
It's an interesting idea. It's quite a big change, and I'm not sure if we can do it in a backwards compatible way. It's because we allow users to register their own commands:
https://piccolo-orm.readthedocs.io/en/latest/piccolo/projects_and_apps/piccolo_apps.html#commands
It's a tricky one. I wonder if we could somehow enhance the CLI without changing libraries.
@dantownsend Thank you
regarding the issue of registering commands, typer allows that:
- cli.register(sum)
+ app.command()(sum)
But since targ does it it is unnecessary to change it. I think what can be improved here is to update the print statements to use rich instead and questionary for asking for input so we are not changing the libraries we are just using some new tools.
Sorry for the slow reply.
I'm kind of torn on it. I've been through the docs, and it is does offer some nice features.
The way argument are documented is a bit different in targ - it's all in the docstring. I'm not sure how easy that would be to convert over 🤔
@dantownsend No Worries.
Typer, plus being apple to use typer.Argument or typer.Option, can also provide help text from docstring
But I suggest, if this was approved, using typer.Argument and typer.Option because it offers an extensive set of features.
Also, adding new features and maintenance, in my opinion, would be much better using typer's arguments and options instead of parsing docstrings!
I think it is worth the effort.
P.S.:- If this was approved I would like to work on it.