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

Re: [PATCH 1/4] parse-options: introduce OPT_PATH

From
Philip Oakley <philipoakley@iee.org>
Date
Feb 23, 2015, 19:45 UTC
Message-ID
<6D98922D49BD42139185BE6A94DDD5DA@PhilipOakley>
In-Reply-To
<cccf3d14e5582996e5be1467849121a262f9c9f1.1424707497.git.git@drmicha.warpmail.net>
From: "Michael J Gruber" <git@drmicha.warpmail.net>
Show 22 quoted lines
> Many options are paths, but not files. Introduce OPT_PATH which does
> the same path processing as OPT_FILENAME but allows to name the 
> argument.
>
> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
> ---
> Documentation/technical/api-parse-options.txt | 5 +++++
> parse-options.h                               | 2 ++
> 2 files changed, 7 insertions(+)
>
> diff --git a/Documentation/technical/api-parse-options.txt 
> b/Documentation/technical/api-parse-options.txt
> index 1f2db31..109903c 100644
> --- a/Documentation/technical/api-parse-options.txt
> +++ b/Documentation/technical/api-parse-options.txt
> @@ -187,6 +187,11 @@ There are some macros to easily define options:
>  The filename will be prefixed by passing the filename along with
>  the prefix argument of `parse_options()` to `prefix_filename()`.
>
> +`OPT_PATH(short, long, &var, arg_str, description)`::
> + Introduce an option with a path argument named arg_str.
> + The filename will be prefixed by passing the filename along with

I couldn't understand this. Should it be s/filename/pathname/ ? Or am I way off topic.

Show 25 quoted lines
> + the prefix argument of `parse_options()` to `prefix_filename()`.
> +
> `OPT_ARGUMENT(long, description)`::
>  Introduce a long-option argument that will be kept in `argv[]`.
>
> diff --git a/parse-options.h b/parse-options.h
> index 7940bc7..5127a5d 100644
> --- a/parse-options.h
> +++ b/parse-options.h
> @@ -149,6 +149,8 @@ struct option {
>    PARSE_OPT_NOARG | PARSE_OPT_NONEG, (f) }
> #define OPT_FILENAME(s, l, v, h)    { OPTION_FILENAME, (s), (l), (v), 
> \
>         N_("file"), (h) }
> +#define OPT_PATH(s, l, v, a, h)    { OPTION_FILENAME, (s), (l), (v), 
> \
> +        (a), (h) }
> #define OPT_COLOR_FLAG(s, l, v, h) \
>  { OPTION_CALLBACK, (s), (l), (v), N_("when"), (h), PARSE_OPT_OPTARG, 
> \
>  parse_opt_color_flag_cb, (intptr_t)"always" }
> -- 
> 2.3.0.296.g32c87e1
>
> --
Philip 
Previous: Michael J GruberNext: Michael J Gruber
Message 8 of 18 in “checkout: --to requires directory”
  1. checkout: --to requires directoryMichael J Gruber, Feb 23, 2015
  2. Jeff KingFeb 23, 2015
  3. Michael J GruberFeb 23, 2015
  4. 0/4 OPT_{FILENAME,PATH}Michael J Gruber, Feb 23, 2015
  5. 1/4 parse-options: introduce OPT_PATHMichael J Gruber, Feb 23, 2015
  6. Junio C HamanoFeb 23, 2015
  7. Michael J GruberFeb 24, 2015
  8. Philip OakleyFeb 23, 2015
  9. 2/4 option-strings: use OPT_FILENAMEMichael J Gruber, Feb 23, 2015
  10. Jeff KingFeb 23, 2015
  11. Junio C HamanoFeb 23, 2015
  12. Junio C HamanoFeb 23, 2015
  13. 3/4 option-strings: use OPT_PATHMichael J Gruber, Feb 23, 2015
  14. Jeff KingFeb 23, 2015
  15. Junio C HamanoFeb 23, 2015
  16. Jeff KingFeb 23, 2015
  17. 4/4 checkout: --to requires directoryMichael J Gruber, Feb 23, 2015
  18. Duy NguyenFeb 24, 2015

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.