Go to the source code of this file.
◆ htils_cli_option_t
A cli option.
- Parameters
-
| name | The name of the option |
| desc | The description of the option |
| cli_short | The short cli arg of the option |
| cli_long | The long cli arg of the option |
| cli_short_short | The short short cli arg of the option |
| has_arg | Whether the option has another argument |
◆ htils_cli_t
The cli state thats used during parsing.
- Parameters
-
| argc | The number of arguments |
| argv | The arguments |
| cli_name | The name of the cli |
| cli_desc | The description of the cli |
| options | The options of the cli |
| arena | The arena to use for allocating memory in the cli parser. |
| usage | The usage function to use when printing the usage of the cli. |
| optidx | The index of the current option being parsed. |
| next_char | The next character to parse. |
| optarg | The argument of the current option being parsed. |
| optopt | The option of the current option being parsed. |
◆ cli_add()
Add an option to the cli.
This will generate short and long option based on the name, and provides a description for the option in the usage command, allowing marking a option as having a required arg.
- Parameters
-
| cli | The cli to add the option to. |
| name | The name of the option. |
| desc | The description of the option. |
| requires_arg | Whether the option requires another argument afterwards. |
- Precondition
cli, name, and desc must be valid and not null.
◆ cli_new()
Create a new cli.
Allocates a new htils_cli_t struct and initializes default values.
- Parameters
-
| arena | The arena to use for allocating memory in the cli parser. |
| argc | The number of arguments |
| argv | The arguments |
| name | The name of the cli |
| desc | The description of the cli |
- Precondition
arena, argc, argv, name, and desc must be valid and not null.
- Returns
- A new htils_cli_t struct.
◆ parse_cli()
Parse the cli through looping.
This will loop through the arguments and parse the cli meant to be used in a while loop, with a switch for the return. If an unknown arg is met it will return '?', if an argument requires another argument, and it wasn't provided, it will return with ':', and if an argument without a required argument suddenly requires one, then it will return with ';'.
- Parameters
-
- Precondition
cli must be valid and not null.
- Returns
- The matched argument, '?', ':', or ';'.