@@ -884,7 +884,9 @@ Level 2 selected.
884884----
885885
886886
887- === Before Actions
887+ === Parsing Actions
888+
889+ ==== Before Actions
888890Before actions operate on the entire argument list, after environment variable
889891and response file expansion, but before any individual arguments are parsed.
890892The before action should:
@@ -954,7 +956,23 @@ That isn't too complicated, but since this case is so common cli.helpNoArgs()
954956is available to do the same thing.
955957
956958
957- === Parse Actions
959+ ==== Transform Actions
960+ Action to take immediately before each source value is parsed. Any
961+ number of transform actions can be added.
962+
963+ The function should:
964+ * Inspect, and/or change the source value via cli.newValue().
965+ * Call cli.badUsage() with an error message if there's a problem.
966+ * Call cli.parseExit() if the program should stop without an error. This could
967+ be due to an early out like "--version" and "--help".
968+
969+ The argument is set, so you can use opt.from() and opt.pos() to get the
970+ option name that the value was matched with on the command line and its
971+ position in argv[]. For bool arguments the val string will always be
972+ either "0" or "1".
973+
974+
975+ ==== Parse Actions
958976Sometimes, you want an argument to completely change the execution flow. For
959977instance, to provide more detailed errors about badly formatted arguments. Or
960978to make "--version" print some crazy ASCII artwork and exit the program (for
@@ -964,8 +982,8 @@ Parsing actions are bound to options and get invoked when a value becomes
964982available for it. Any std::function compatible object that accepts references
965983to cli, opt, and string as parameters can be used. The function should:
966984
967- * Parse the source string and use the result to set the option value (or
968- push back the additional value for vector arguments ).
985+ * Parse the source string and use the result to update the option value (or
986+ value vector).
969987* Call cli.badUsage() with an error message if there's a problem.
970988* Call cli.parseExit() if the program should stop. This could be due to an
971989 early out like "--version" and "--help".
@@ -1017,7 +1035,7 @@ Error: Invalid '-n' value: x
10171035----
10181036
10191037
1020- === Check Actions
1038+ ==== Check Actions
10211039Check actions run for each value that is successfully parsed and are a good
10221040place for additional work. For example, opt.range() and opt.clamp() are
10231041implemented as check actions. Just like parse actions the callback is any
@@ -1074,7 +1092,7 @@ $ a.out --socks 3
10741092----
10751093
10761094
1077- === After Actions
1095+ ==== After Actions
10781096After actions run after all arguments have been parsed. For example,
10791097opt.prompt() and opt.require() are both implemented as after actions. Any
10801098number of after actions can be added and will, for every (not just the ones
0 commit comments