optimato / lab-control-lib

Laboratory Control Library
2 stars 2 forks source link

command line interface #3

Open decarlof opened 7 months ago

decarlof commented 7 months ago

@pierrethibault during the presentation we discussed about improving the command line interface. I have been using argparse together with a config.py file to create a cli that allows, among other things, to:

If you think this is useful I can add a template to the project, I just a list of parameters to start with

pierrethibault commented 7 months ago

Thanks for offering! Sure please add the template somewhere.

For now the cli depends on Click, which I found is a quite convenient way to deal with that. But I am happy alternative suggestions.

decarlof commented 7 months ago

The results/functionalities are very similar to what I have (see as an example of one of my projects the end of this page) but Click seems much easier to implement.

In my case I use a config.py file where I define the parameters, then in the main.py I use this code to associate each command with the corresponding set of parameters. As I said they deliver the same but Click seems more elegant.

One question: does Click has the option to store the last set of used parameters, i.e. if the command is called again without any parameters will run with the last used instead of the default?

This is an option I found very useful with project using a very large set of parameters (see the config.py of tomopy-cli for example)