Installs a new command line to be accepted.
This functions allows you to install new arguments to be accepted. Every argument passed in to the program which is not installed throught this function will no be accepted and will generate a non recognized command line error.
Let's see an example on how to use exarg to install the --version argument. You should call exarg as follows:
Previous line have installed a argument called "version" which will be invoked by the user as --version. The short alias in this case is "v" which as we have see will allow user to invoke your program as -v.
Because you could install arguments which may conflict, this function will abort the program execution on that case. This will ensure you, as programer, to have a binary compiled with no problems due to exarg.
Later on, you can use exarg_is_defined to check the status of installed arguments. Once you install an argument the user may invoke it and you could check that status using previous function. Because the "version" argument type is EXARG_NONE you can only use exarg_is_defined. But, for other argument types as EXARG_STRING, you can also use exarg_get_string function to get the value defined by user. Let's see an example.
This previous line will allow user to invoke your program as --load-library path/to/lib. Then you can use exarg_get_string to get the path/to/lib value by using:
You must install all argument before calling exarg_parse. That function will parse argument options by using installed arguments. Check the info about that function.
ExArg is not thread-safe which doesn't means anything wrong but you must call all exarg function from the same thread to get the right results.
This function will not do a copy from arg_name, arg_short_name or description. This means you should not free that values while using exarg. To end exarg using check exarg_end. It is recomended to use static values and shows on previous examples.