Skip to content

Commit 4077f1c

Browse files
committed
adopt: move simple parser to the top of the header
1 parent 44dfaa0 commit 4077f1c

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

adopt.h

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,25 @@ typedef struct adopt_parser {
211211
in_short : 1;
212212
} adopt_parser;
213213

214+
/**
215+
* Parses all the command-line arguments and updates all the options using
216+
* the pointers provided. Parsing stops on any invalid argument and
217+
* information about the failure will be provided in the opt argument.
218+
*
219+
* This is the simplest way to parse options; it handles the initialization
220+
* (`parser_init`) and looping (`parser_next`).
221+
*
222+
* @param opt The The `adopt_opt` information that failed parsing
223+
* @param specs A NULL-terminated array of `adopt_spec`s that can be parsed
224+
* @param args The arguments that will be parsed
225+
* @param args_len The length of arguments to be parsed
226+
*/
227+
adopt_status_t adopt_parse(
228+
adopt_opt *opt,
229+
const adopt_spec specs[],
230+
char **args,
231+
size_t args_len);
232+
214233
/**
215234
* Initializes a parser that parses the given arguments according to the
216235
* given specifications.
@@ -240,22 +259,6 @@ adopt_status_t adopt_parser_next(
240259
adopt_opt *opt,
241260
adopt_parser *parser);
242261

243-
/**
244-
* Parses all the command-line arguments and updates all the options using
245-
* the pointers provided. Parsing stops on any invalid argument and
246-
* information about the failure will be provided in the opt argument.
247-
*
248-
* @param opt The The `adopt_opt` information that failed parsing
249-
* @param specs A NULL-terminated array of `adopt_spec`s that can be parsed
250-
* @param args The arguments that will be parsed
251-
* @param args_len The length of arguments to be parsed
252-
*/
253-
adopt_status_t adopt_parse(
254-
adopt_opt *opt,
255-
const adopt_spec specs[],
256-
char **args,
257-
size_t args_len);
258-
259262
/**
260263
* Prints the status after parsing the most recent argument. This is
261264
* useful for printing an error message when an unknown argument was

0 commit comments

Comments
 (0)