]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/opt.h
Extended types: Cleaned up unit name parsing
[libucw.git] / ucw / opt.h
index 695f607e421e9bbf5e81e31c19c165dbe09103ed..20df7fd7b340d5277c4e34ed175d2b39988c8b36 100644 (file)
--- a/ucw/opt.h
+++ b/ucw/opt.h
@@ -63,6 +63,8 @@
  *   contents of another list of options.
  * - `OPT_CL_HELP`: no option, just print a help text.
  * - `OPT_CL_HOOK`: no option, but a definition of a <<hooks,hook>>.
+ * - `OPT_CL_BREAK`: when a given option occurs, stop parsing and keep
+ *   the option in the argument list.
  ***/
 
 enum opt_class {
@@ -76,6 +78,7 @@ enum opt_class {
   OPT_CL_SECTION,
   OPT_CL_HELP,
   OPT_CL_HOOK,
+  OPT_CL_BREAK,
 };
 
 /***
@@ -131,6 +134,7 @@ struct opt_item {
 #define OPT_MULTIPLE       0x200       /** The option may appear multiple times; will save all the values into a simple list. **/
 #define OPT_SEEN_AS_LONG    0x400      // Used internally to signal that we currently process the long form of the option
 #define OPT_BEFORE_CONFIG   0x800      /** The option may appear before a config file is loaded. **/
+#define OPT_HELP_COL        0x1000     /** Used for OPT_CL_HELP to signal that tabs switch columns. **/
 #define OPT_INTERNAL        0x4000     // Used internally to ask for passing of struct opt_context to OPT_CALL
 
 /**
@@ -158,6 +162,9 @@ struct opt_item {
 /** No option, just a piece of help text. **/
 #define OPT_HELP(line) { .help = line, .cls = OPT_CL_HELP }
 
+/** Like OPT_HELP, but the help text uses tab characters to switch columns like help text for ordinary options does. **/
+#define OPT_HELP_COLUMNS(line) { .help = line, .flags = OPT_HELP_COL, .cls = OPT_CL_HELP }
+
 /** Standard `--help` option. **/
 #define OPT_HELP_OPTION OPT_CALL(0, "help", opt_handle_help, NULL, OPT_BEFORE_CONFIG | OPT_INTERNAL | OPT_NO_VALUE, "\tShow this help")
 
@@ -206,6 +213,9 @@ struct opt_item {
 /** Incrementing option. @target should be a variable of type `int`. **/
 #define OPT_INC(shortopt, longopt, target, fl, desc) { .letter = shortopt, .name = longopt, .ptr = CHECK_PTR_TYPE(&target, int *), .flags = fl, .help = desc, .cls = OPT_CL_INC, .type = CT_INT }
 
+/** Breakpoint option. When this option occurs, parsing is terminated and the option is kept in the argument array. **/
+#define OPT_BREAK(shortopt, longopt, fl) { .letter = shortopt, .name = longopt, .flags = fl, .cls = OPT_CL_BREAK }
+
 /* FIXME: Backwards compatibility only, should not be used anymore. */
 #define OPT_UNS OPT_UINT
 #define OPT_UNS_MULTIPLE OPT_UINT_MULTIPLE