]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/opt-test.c
Opt: Documented opt and its interaction with conf
[libucw.git] / ucw / opt-test.c
index cd7acc38f5f27009dd537c3cfcebe1debfdc1987..b9bedde5160a8621c314b7a1524e39392f907a71 100644 (file)
@@ -97,7 +97,7 @@ static struct cf_user_type teapot_temperature_t = {
   .dumper = (cf_dumper1*) teapot_temperature_dumper
 };
 
-static void opt_test_hook(struct opt_item * opt, const char * value, void * data) {
+static void opt_test_hook(struct opt_item * opt, uns event UNUSED, const char * value, void * data) {
   if (!show_hooks)
     return;
   if (opt)
@@ -114,16 +114,17 @@ static struct opt_section water_options = {
   }
 };
 
-static struct opt_section help = {
+static struct opt_section options = {
   OPT_ITEMS {
     OPT_HELP("A simple tea boiling console."),
     OPT_HELP("Usage: teapot [options] name-of-the-tea"),
+    OPT_HELP(""),
     OPT_HELP("Black, green or white tea supported as well as fruit or herbal tea."),
     OPT_HELP("You may specify more kinds of tea, all of them will be boiled for you, in the given order."),
     OPT_HELP("At least one kind of tea must be specified."),
     OPT_HELP(""),
     OPT_HELP("Options:"),
-    OPT_HELP_OPTION(help),
+    OPT_HELP_OPTION,
     OPT_CALL('V', "version", show_version, NULL, OPT_NO_VALUE, "\tShow the version"),
     OPT_HELP(""),
     OPT_BOOL('e', "english-style", english, 0, "\tEnglish style (with milk)"),
@@ -139,17 +140,19 @@ static struct opt_section help = {
              "\t\tOnly integer values allowed."),
     OPT_INC('v', "verbose", verbose, 0, "\tVerbose (the more -v, the more verbose)"),
     OPT_INC('q', "quiet", verbose, OPT_NEGATIVE, "\tQuiet (the more -q, the more quiet)"),
-    OPT_INT('b', "black-magic", black_magic, OPT_MULTIPLE, "<strength>\tUse black magic to make the tea extraordinary delicious.\n\t\tMay be specified more than once to describe the amounts of black magic to be invoked in each step of tea boiling."),
+    OPT_INT('b', NULL, black_magic, OPT_MULTIPLE, "<strength>\tUse black magic to make the tea extraordinarily delicious.\n\t\tMay be specified more than once to describe the amounts of black magic to be invoked in each step of tea boiling."),
     OPT_BOOL('p', "pray", pray, OPT_SINGLE, "\tPray before boiling"),
-    OPT_STRING(OPT_POSITIONAL(1), NULL, first_tea, OPT_REQUIRED | OPT_NO_HELP, ""),
-    OPT_CALL(OPT_POSITIONAL_TAIL, NULL, add_tea, &tea_list, OPT_NO_HELP, ""),
+    OPT_STRING(OPT_POSITIONAL(1), NULL, first_tea, OPT_REQUIRED, ""),
+    OPT_CALL(OPT_POSITIONAL_TAIL, NULL, add_tea, &tea_list, 0, ""),
     OPT_HELP(""),
     OPT_HELP("Water options:"),
     OPT_SECTION(water_options),
     OPT_HOOK(opt_test_hook, "prearg", OPT_HOOK_BEFORE_ARG),
     OPT_HOOK(opt_test_hook, "preval", OPT_HOOK_BEFORE_VALUE),
     OPT_HOOK(opt_test_hook, "postval", OPT_HOOK_AFTER_VALUE),
-    OPT_BOOL('H', "show-hooks", show_hooks, 0, "Demonstrate the hooks."),
+    OPT_BOOL('H', "show-hooks", show_hooks, 0, "\tDemonstrate the hooks."),
+    OPT_HELP(""),
+    OPT_HELP("Configuration options:"),
     OPT_CONF_OPTIONS,
     OPT_END
   }
@@ -162,8 +165,9 @@ struct intnode {
 
 int main(int argc UNUSED, char ** argv)
 {
+  cf_def_file = "etc/libucw";
   clist_init(&black_magic);
-  opt_parse(&help, argv+1);
+  opt_parse(&options, argv+1);
 
   printf("English style: %s|", english ? "yes" : "no");
   if (sugar)