If the path to the Gnucash file is like C:\Temp\Comité\myfile.gnucash on
a Windows PC, the file will not be found. This also applies to the log
file when --logto C:\Temp\Comité\mylog.txt
This fixes the presence of the 'input-file' command line option.
It's an implementation detail that wasn't meant to be listed in help.
The way to fix it is keeping two option_description variables. One
with all possible values to parse and one with only those to present
to the user
Note this required the introduction of a '--name' parameter
for the report name to run. Without it the command line
would have to support a variable number of positional
parameters, depending on the context (quotes or report)
and that would complicate the parsing considerably.
The program options libary has a convenience binding for boost::optional
to indicate whether an option is set or not.
Use this to store options passed on the command line directly
in variables for later use. This avoids the need to refer to options
in several locations using a fixed string (like 'help', 'help-gtk', 'nofile',...)
In addition drop a number of obsolete class member variables.
They were leftovers from the conversion to c++ and no longer used.
As gnucash and most gnucash-cli commands will work on an input file
it makes sense to use the common positional input-file parameter everywhere.
It's still optional for a normal gnucash run though. It will fall back to
to last-used file as before.
A --add-price-quotes run on the other hand will bail out with an error
message. As this command is typically run unattended in a cron script
it's safer to explicitly request a file to work on.
Right now it doesn't make a difference as the end of main
is currently never reached. However with some additional
tweaks it can be, and that would allow the application
destructor to be called for a nicer cleanup on exit.
Contrary to gtk_init, boost::program_options won't remove parsed options from
the argument list so there's no need to provide the option to update
the list.
- Remove unneeded includes, required a few fixes in other header files
- Silence unused parameter warnings using c++17 attribute [[maybe_unused]]
- Remove some duplicate, unused functions from gnucash and gnucash-cli
They were a left over from a previous commit
This is just a first start, more refactoring will follow in later commits.
The idea is to have an application class that provides the basic framework
gnucash and gnucash-cli will become specializations of this class adding their
specific functionality. I'm splitting this over several commits to be able to
keep track of all the many changes.
This tool is intended to expose certain gnucash functions to a command line interface.
The first one is --add-price-quotes. This option currently also exists in gnucash.
It will be marked deprecated there. Future extensions to this can be things like
report generation, non-interactive imports,...