I am working on a command line tool that can read the options:
- < Li>
- An optional configuration file
I used to read those options and it works mostly well.
My code is like this:
Namespace = po = boost :: program_options; Name space fs = boost :: filesystem; Po :: variables_map vm; Po :: store (po :: parse_command_line (argc, argv, option), vm); Po :: store (po :: parse_config_file (ifs, options, true), vm); Po :: Notify (VM);
However, some of these options are file paths and I want them to be relative to the origin of the option. Here's an example of what I mean:
Assume that my tool is located in: / usr / local / bin
mytool - After parsing - Foo.path ../config/assets/toto.txt
, the foo.path
option is the absolute path of the / usr Should be /local/config/assets/toto.txt
.
Now if I specify foo.path
in a configuration file, which is located at / usr / local /config/myconf.cfg
The same happens:
foo.path = assets / toto.txt
I like the path, not according to the configuration file (execution path) And as a result the full path will be the same as before.
Does the value of an option come from so that I can adjust the path when completely transforming the relative path?
No comments:
Post a Comment