-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ void usage(std::ostream &os) { | |
"CLI:\n" | ||
"-h [ --help ] print this help text and exit\n" | ||
"-i [ --info ] print information about current outputs and exit\n" | ||
"-f [ --file ] arg use file as config\n" | ||
"-n [ --noop ] perform a trial run and exit\n" | ||
"-v [ --version ] print version string\n" | ||
"\n" | ||
|
@@ -99,6 +100,7 @@ void parseArgs(int argc, char **argv, Settings &settings) { | |
static struct option long_options[] = { | ||
{ "help", no_argument, 0, 'h' }, | ||
{ "info", no_argument, 0, 'i' }, | ||
{ "file", required_argument, 0, 'f' }, | ||
{ "noop", no_argument, 0, 'n' }, | ||
{ "version", no_argument, 0, 'v' }, | ||
{ "dpi", required_argument, 0, 'd' }, | ||
|
@@ -109,7 +111,7 @@ void parseArgs(int argc, char **argv, Settings &settings) { | |
{ "quiet", no_argument, 0, 'q' }, | ||
{ 0, 0, 0, 0 } | ||
}; | ||
static const char *short_options = "hinvd:r:mo:p:q"; | ||
static const char *short_options = "hif:nvd:r:mo:p:q"; | ||
|
||
bool orderFromFile = !settings.order.empty(); | ||
|
||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Please test Something simple like "config file /path/to/.xlayoutdisplay not found, exiting" |
||
parseCfgFile(ifs, settings); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
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. |
||
} | ||
break; | ||
case 'n': | ||
settings.noop = true; | ||
break; | ||
|
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"