enum modes {
MODE_UNKNOWN = 0,
MODE_QUERY = (1 << 0),
+ MODE_PARSE = (1 << 1),
};
static int mode = MODE_UNKNOWN;
char *queryformat = NULL;
static struct poptOption specOptsTable[] = {
+ { "parse", 'P', POPT_ARG_VAL, &mode, MODE_PARSE,
+ N_("parse spec file(s) to stdout"), NULL },
{ "query", 'q', POPT_ARG_VAL, &mode, MODE_QUERY,
N_("query spec file(s)"), NULL },
{ "rpms", 0, POPT_ARG_VAL, &source, RPMQV_SPECRPMS,
ec = rpmcliQuery(ts, qva, (ARGV_const_t) poptGetArgs(optCon));
break;
+ case MODE_PARSE: {
+ const char * spath;
+ if (!poptPeekArg(optCon))
+ argerror(_("no arguments given for parse"));
+
+ while ((spath = poptGetArg(optCon)) != NULL) {
+ rpmSpec spec = rpmSpecParse(spath, 0, NULL);
+ if (spec == NULL) {
+ ec++;
+ continue;
+ }
+ fprintf(stdout, "%s", rpmSpecGetSection(spec, RPMBUILD_NONE));
+ rpmSpecFree(spec);
+ }
+ break;
+ }
+
case MODE_UNKNOWN:
if (poptPeekArg(optCon) != NULL || argc <= 1 || rpmIsVerbose()) {
printUsage(optCon, stderr, 0);