git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3 1/5] parse-options: Allow PARSE_OPT_NOARG in integer arguments

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Aug 21, 2010, 03:39 UTC
Message-ID
<20100821033916.GA2206@burratino>
In-Reply-To
<20100820200148.GE6211@kytes>
Hi Ram,

[rearranged for convenience] Ramkumar Ramachandra wrote:

> Let's say I want to have an option that takes an
> integer argument, say `foo`. To set it to the integer argument 42, I
> can say `--foo=42`. To set it to its default value, I could earlier
> say `--foo=`. With this patch I can simply say `--foo`. Makes sense?
I think you want OPTARG ("optional argument").

What your patch would allow is using OPTION_INTEGER for boolean options, where people use OPT_SET_INT now. Maybe that would be a good cleanup, but I am not convinced it is worth the churn.

> Junio C Hamano writes:
>> Doesn't NOARG mean "Do not take an argument, if you give me an argument
>> that is an error"?
>
> Oh, does it mean that?
Yes.
-- 8< --
Subject: parse-options: clarify PARSE_OPT_NOARG description

Here "takes no argument" means "does not take an argument". The latter phrasing might make it clearer that PARSE_OPT_NOARG does not make an option with an argument that can optionally be left off.

Noticed-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
diff --git a/parse-options.h b/parse-options.h
index 7435cdb..d982f0f 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -69,7 +69,7 @@ typedef int parse_opt_cb(const struct option *, const char *arg, int unset);
  * `flags`::
  *   mask of parse_opt_option_flags.
  *   PARSE_OPT_OPTARG: says that the argument is optional (not for BOOLEANs)
- *   PARSE_OPT_NOARG: says that this option takes no argument
+ *   PARSE_OPT_NOARG: says that this option does not take an argument
  *   PARSE_OPT_NONEG: says that this option cannot be negated
  *   PARSE_OPT_HIDDEN: this option is skipped in the default usage, and
  *                     shown only in the full usage.
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 5 of 15 in “fmt-merge-msg improvements”
  1. 0/5 fmt-merge-msg improvementsRamkumar Ramachandra, Aug 20, 2010
  2. 1/5 parse-options: Allow PARSE_OPT_NOARG in integer argumentsRamkumar Ramachandra, Aug 20, 2010
  3. Junio C HamanoAug 20, 2010
  4. Ramkumar RamachandraAug 20, 2010
  5. Jonathan NiederAug 21, 2010
  6. 2/5 fmt-merge-msg: Make the number of log entries in commit message configurableRamkumar Ramachandra, Aug 20, 2010
  7. Jonathan NiederAug 21, 2010
  8. Ramkumar RamachandraAug 21, 2010
  9. 3/5 fmt-merge-msg: Update command line options to sync with config optionsRamkumar Ramachandra, Aug 20, 2010
  10. Jonathan NiederAug 21, 2010
  11. Ramkumar RamachandraAug 21, 2010
  12. 4/5 fmt-merge-msg: Remove deprecated --summary optionRamkumar Ramachandra, Aug 20, 2010
  13. Jonathan NiederAug 21, 2010
  14. Ramkumar RamachandraAug 21, 2010
  15. 5/5 fmt-merge-msg: Update fmt-merge-msg and merge-config documentationRamkumar Ramachandra, Aug 20, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.