1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
;
/**
* Invoked when a subcommand is encountered. argc and argv[] begins at the command encounterd.
* command_name is the name of the command being handled.
*/
typedef int;
/**
* Dispatch table to dispatch cli commands from.
* command_name should be the exact string for the command you want to handle from the command line.
*/
;
/* Ignoring padding since we're trying to maintain getopt.h compatibility */
/* NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding) */
;
/**
* Initialized to 1 (for where the first argument would be). As arguments are parsed, this number is the index
* of the next argument to parse. Reset this to 1 to parse another set of arguments, or to rerun the parser.
*/
AWS_COMMON_API extern int aws_cli_optind;
/**
* If an option has an argument, when the option is encountered, this will be set to the argument portion.
*/
AWS_COMMON_API extern const char *aws_cli_optarg;
/**
* If 0x02 was returned by aws_cli_getopt_long(), this value will be set to the argument encountered.
*/
AWS_COMMON_API extern const char *aws_cli_positional_arg;
/**
* A mostly compliant implementation of posix getopt_long(). Parses command-line arguments. argc is the number of
* command line arguments passed in argv. optstring contains the legitimate option characters. The option characters
* coorespond to aws_cli_option::val. If the character is followed by a :, the option requires an argument. If it is
* followed by '::', the argument is optional (not implemented yet).
*
* longopts, is an array of struct aws_cli_option. These are the allowed options for the program.
* The last member of the array must be zero initialized.
*
* If longindex is non-null, it will be set to the index in longopts, for the found option.
*
* Returns option val if it was found, '?' if an option was encountered that was not specified in the option string,
* 0x02 (START_OF_TEXT) will be returned if a positional argument was encountered. returns -1 when all arguments that
* can be parsed have been parsed.
*/
AWS_COMMON_API int ;
/**
* Resets global parser state for use in another parser run for the application.
*/
AWS_COMMON_API void ;
/**
* Dispatches the current command line arguments with a subcommand from the second input argument in argv[], if
* dispatch table contains a command that matches the argument. When the command is dispatched, argc and argv will be
* updated to reflect the new argument count. The cli options are required to come after the subcommand. If either, no
* dispatch was found or there was no argument passed to the program, this function will return AWS_OP_ERR. Check
* aws_last_error() for details on the error.
* @param argc number of arguments passed to int main()
* @param argv the arguments passed to int main()
* @param parse_cb, optional, specify NULL if you don't want to handle this. This argument is for parsing "meta"
* commands from the command line options prior to dispatch occurring.
* @param dispatch_table table containing functions and command name to dispatch on.
* @param table_length numnber of entries in dispatch_table.
* @return AWS_OP_SUCCESS(0) on success, AWS_OP_ERR(-1) on failure
*/
AWS_COMMON_API int ;
/* AWS_COMMON_COMMAND_LINE_PARSER_H */