Thread (21 messages) flat view 21 messages, 3 authors, 2016-06-15
STALE3732d

[PATCH 06/10] parse-options: never suppress arghelp if LITERAL_ARGHELP is set

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:50:09
Subsystem: the rest · Maintainer: Linus Torvalds

The PARSE_OPT_LITERAL_ARGHELP flag allows a program to override the
standard "<argument> for mandatory, [argument] for optional" markup in
its help message.  Extend it to override the usual "no text for
disallowed", too (for the PARSE_OPT_NOARG | PARSE_OPT_LITERAL_ARGHELP
case, which was previously meaningless), to be more intuitive.

The motivation is to allow update-index to correctly advertise

	--cacheinfo <mode> <object> <path>
	                      add the specified entry to the index

while abusing PARSE_OPT_NOARG to disallow the "sticked form"

	--cacheinfo=<mode> <object> <path>

Noticed-by: Stephen Boyd [off-list ref]
Signed-off-by: Jonathan Nieder <redacted>
---
This seems like the intuitive thing to do, but the motivating use case
is iffy.  Might be better to introduce a PARSE_OPT_NOSTICKED flag.

 parse-options.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/parse-options.c b/parse-options.c
index 684d330..b640ac5 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -533,7 +533,8 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
 		if (opts->type == OPTION_NUMBER)
 			pos += fprintf(outfile, "-NUM");
 
-		if (!(opts->flags & PARSE_OPT_NOARG))
+		if ((opts->flags & PARSE_OPT_LITERAL_ARGHELP) ||
+		    !(opts->flags & PARSE_OPT_NOARG))
 			pos += usage_argh(opts, outfile);
 
 		if (pos <= USAGE_OPTS_WIDTH)
-- 
1.7.2.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help