Product SiteDocumentation Site

Handling rpm command-line options

The RPM C library makes extensive use of popt for processing command-line arguments. Functions that set up the RPM library, such as rpmcliInit, which sets up the RPM command-line environment, require a table of poptOption entries that define the command-line options for your program.
To create a simple program that handles the standard rpm command-line options, set up the following options table:
static struct poptOption optionsTable[] = {
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
"Common options for all rpm modes and executables:",
NULL },
POPT_AUTOALIAS
POPT_AUTOHELP
POPT_TABLEEND
};
Then, initialize your program with a call to rpmcliInit:
poptContext rpmcliInit(int argc, char *const argv[],
struct poptOption * optionsTable);
When you call rpmcliInit, it will set up all the variables for the standard rpm command-line options.
For example, to see if the verbose flag is turned on, call rpmIsVerbose:
int rpmIsVerbose();
When you are done with a program that called rpmcliInit, call rpmcliFini to clean up the global data:
poptContext rpmcliFini(poptContext context);
The call to rpmcliFini returns NULL.