SOLO Activity: Command line interface
A command line interface (CLI) is a good way to allow non-developers to use your software. In the previous lesson we saw how we can separate the functionality of your software from the user interface by creating a module with the core functionality and a script to provide the user interface.
Using the example project we developed earlier:
- Update the
scripts/sim_catalog
file so that it now has two argument groups,- The current
group1
should have atitle
of “Program settings” - The second group (
group2
) should have atitle
of “Metadata”
- The current
- Add the following parameters to
group2
:--version
, which will print the version--date
, to show the last modified date--author
, to list the authors
- All the parameters in
group2
should have adefault
value ofFalse
, and then useaction='store_true'
to set the parameter toTrue
when this option is supplied by the user. - [Optional] Provide shortened versions of the parameters in
group2
of the format-c
etc.. - Write the necessary code so that when any of the options in
group2
are set, all the required information is printed and the program exits without performing the simulation.- For now you’ll have to define some variables within the script to hold these values, but later on we’ll demonstrate a better place to store them.