brentyi / tyro

CLI interfaces & config objects, from types
https://brentyi.github.io/tyro
MIT License
467 stars 23 forks source link

Question: Centralised CLI for reports #133

Closed b4rlw closed 5 months ago

b4rlw commented 5 months ago

I'm interested in building a centralised CLI for a report scripts repo. The repo is structured such that each report is its own module with a main function, and a report can have args that are unique only to it.

Does Tyro support any way of amalgamating all those main functions into a centralised CLI, perhaps with "run" and "list" subcommands, or would I need to build this more manually with argparse?

brentyi commented 5 months ago

Hi, sorry for missing this!

I'm not sure about run and list specifically, but this example might be relevant to you: https://brentyi.github.io/tyro/examples/02_nesting/05_subcommands_func/

You could pass tyro.extras.subcommand_cli_from_dict() a dictionary that maps each report name to its respective main function.

b4rlw commented 5 months ago

Thanks for the guidance, I'll try that!