-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable option to read config from specific file #21
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, works.
Thanks for the contribution.
Please add new option to:
- README.md
@@ -126,6 +128,12 @@ void parseArgs(int argc, char **argv, Settings &settings) { | |||
case 'i': | |||
settings.info = true; | |||
break; | |||
case 'f': | |||
{ | |||
ifstream ifs(optarg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please test ifs
and error/exit if not found.
Something simple like "config file /path/to/.xlayoutdisplay not found, exiting"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, works.
Thanks for the contribution.
@@ -126,6 +128,12 @@ void parseArgs(int argc, char **argv, Settings &settings) { | |||
case 'i': | |||
settings.info = true; | |||
break; | |||
case 'f': | |||
{ | |||
ifstream ifs(optarg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please test ifs
and error/exit if not found.
Something simple like "config file /path/to/.xlayoutdisplay not found, exiting"
case 'f': | ||
{ | ||
ifstream ifs(optarg); | ||
parseCfgFile(ifs, settings); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Settings from the default config files will be present. Any settings from the defaults that are not present in this file will still remain in the settings. Also, depending on invocation order, command line arguments may be overridden by the settings file.
Possible solutions:
- destroy existing settings before reading -f
- do not read default files when -f
- read file and CLI settings separately then merge them
First two would require a "two pass" approach to reading arguments, the first lookng for -f and reading it prior to parsing the rest of the command line arguments.
I'll merge this one after #20 |
Enable
-f
option for user to specify a file as the config to read from