hydrogen-music / hydrogen

The advanced drum machine for Linux, macOS, and Windows
http://www.hydrogen-music.org
GNU General Public License v2.0
1.04k stars 173 forks source link

Add shared parser between `hydrogen` main routine and `Reporter` #1989

Closed theGreatWhiteShark closed 2 months ago

theGreatWhiteShark commented 3 months ago

Since the introduction of the CLI arg -L to use a custom log file we are in a somewhat inconsistent state. The Reporter is trying to open the log file after a crash using Filesystem::log_file_path. But since this is accessing a static variable of the Filesystem class it is not enough to just parse the log file in the child process. This one will be lost and the Reporter can not do anything than accessing the default log file.

So, Reporter needs to set the custom log file as well. Here we are a bit in a pickle. I do not want to resort to manually or "old school" CLI arg parsing like the one I just modernized in h2cli. On the other side, we do not want to duplicate all the CLI options in Reporter but we would have to for Qt-style parsing. Else the parser might reject some valid options we missed to add and hydrogen would not start up anymore (unless combined with --child). Therefore, I decided to move all the parsing into a separate class - Parser - used in both places.