aboutsummaryrefslogtreecommitdiffstats
path: root/src/redshift.c
diff options
context:
space:
mode:
authorJon Lund Steffensen <jonlst@gmail.com>2010-05-27 00:17:47 +0200
committerJon Lund Steffensen <jonlst@gmail.com>2010-05-27 00:17:47 +0200
commit19f734335519996395113c6acbde949dfc60e167 (patch)
tree9bb21c48b0791aee476953bc2efb3ae5044d2708 /src/redshift.c
parentRemove unused parameters in help text output. (diff)
downloadredshift-ng-19f734335519996395113c6acbde949dfc60e167.tar.gz
redshift-ng-19f734335519996395113c6acbde949dfc60e167.tar.bz2
redshift-ng-19f734335519996395113c6acbde949dfc60e167.tar.xz
Let gamma methods and location providers print help on option parameters.
Diffstat (limited to 'src/redshift.c')
-rw-r--r--src/redshift.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/redshift.c b/src/redshift.c
index fd14a64..e2d8964 100644
--- a/src/redshift.c
+++ b/src/redshift.c
@@ -97,6 +97,7 @@ static const gamma_method_t gamma_methods[] = {
"RANDR",
(gamma_method_init_func *)randr_init,
(gamma_method_free_func *)randr_free,
+ (gamma_method_print_help_func *)randr_print_help,
(gamma_method_restore_func *)randr_restore,
(gamma_method_set_temperature_func *)randr_set_temperature
},
@@ -106,6 +107,7 @@ static const gamma_method_t gamma_methods[] = {
"VidMode",
(gamma_method_init_func *)vidmode_init,
(gamma_method_free_func *)vidmode_free,
+ (gamma_method_print_help_func *)vidmode_print_help,
(gamma_method_restore_func *)vidmode_restore,
(gamma_method_set_temperature_func *)vidmode_set_temperature
},
@@ -115,6 +117,7 @@ static const gamma_method_t gamma_methods[] = {
"WinGDI",
(gamma_method_init_func *)w32gdi_init,
(gamma_method_free_func *)w32gdi_free,
+ (gamma_method_print_help_func *)w32gdi_print_help,
(gamma_method_restore_func *)w32gdi_restore,
(gamma_method_set_temperature_func *)w32gdi_set_temperature
},
@@ -139,6 +142,8 @@ static const location_provider_t location_providers[] = {
"GNOME-Clock",
(location_provider_init_func *)location_gnome_clock_init,
(location_provider_free_func *)location_gnome_clock_free,
+ (location_provider_print_help_func *)
+ location_gnome_clock_print_help,
(location_provider_get_location_func *)
location_gnome_clock_get_location
},
@@ -147,6 +152,8 @@ static const location_provider_t location_providers[] = {
"Manual",
(location_provider_init_func *)location_manual_init,
(location_provider_free_func *)location_manual_free,
+ (location_provider_print_help_func *)
+ location_manual_print_help,
(location_provider_get_location_func *)
location_manual_get_location
},
@@ -288,6 +295,11 @@ print_method_list()
for (int i = 0; gamma_methods[i].name != NULL; i++) {
printf(" %s\n", gamma_methods[i].name);
}
+
+ fputs("\n", stdout);
+ fputs(_("Specify colon-separated options with"
+ " `-m METHOD:OPTIONS'.\n"), stdout);
+ fputs(_("Try `-m METHOD:help' for help.\n"), stdout);
}
static void
@@ -297,6 +309,11 @@ print_provider_list()
for (int i = 0; location_providers[i].name != NULL; i++) {
printf(" %s\n", location_providers[i].name);
}
+
+ fputs("\n", stdout);
+ fputs(_("Specify colon-separated options with"
+ "`-l PROVIDER:OPTIONS'.\n"), stdout);
+ fputs(_("Try `-l PROVIDER:help' for help.\n"), stdout);
}
@@ -406,6 +423,13 @@ main(int argc, char *argv[])
" `%s'.\n"), provider_name);
exit(EXIT_FAILURE);
}
+
+ /* Print provider help if arg is `help'. */
+ if (provider_args != NULL &&
+ strcasecmp(provider_args, "help") == 0) {
+ provider->print_help(stdout);
+ exit(EXIT_FAILURE);
+ }
break;
case 'm':
/* Print list of methods if argument is `list' */
@@ -414,6 +438,13 @@ main(int argc, char *argv[])
exit(EXIT_SUCCESS);
}
+ /* Split off method arguments. */
+ s = strchr(optarg, ':');
+ if (s != NULL) {
+ *(s++) = '\0';
+ method_args = s;
+ }
+
/* Lookup argument in gamma methods table */
for (int i = 0; gamma_methods[i].name != NULL; i++) {
const gamma_method_t *m =
@@ -430,6 +461,13 @@ main(int argc, char *argv[])
optarg);
exit(EXIT_FAILURE);
}
+
+ /* Print method help if arg is `help'. */
+ if (method_args != NULL &&
+ strcasecmp(method_args, "help") == 0) {
+ method->print_help(stdout);
+ exit(EXIT_FAILURE);
+ }
break;
case 'o':
one_shot = 1;