I am experimenting to replace present command line parsing in gramps/cli/argparser.py with Python-library argparse but I stumble upon an unexpected issue.
Gramps may be started from a console, in which case the command line is exactly what user typed. Gramps may also be started from the desktop, in which case the desktop manager will add “technical” options related to the widget library, mainly GTK+ but other desktop manager may be used like Qt for Plasma Desktop, like --screen=
or --display=
.
These “technical” options must not be considered errors by the parser which must ignore them. This is handled by adding them in LONGOPTS=[…] in gramps/gen/const.py. They will be takien into account later when a GrampsApplication(Gtk.Application) is created for GUI operation.
However this results in two problems:
- the need to enumerate the widget options so that they are not considered errors and a constraint on source code maintenance to keep the list up-to-date
- a possible discrepancy if Gramps is launched in a non-GTK+ desktop (but with GTK+ library installed) where the desktop will provide options related to its own library.
How can we liberate Gramps from these “technical” options in order to focus command line parsing only on Gramps matter?
PS: HELP string shows a --load-module options withut explaining it. It is not processed in Gramps, either. I doubt it is a Python interpreter option. Could it be a GTK+ option? In which case why was this one explicitly included in the Help string and not the others?