{"repo", required_argument, 0, 'r'},
// rug compatibility option, we have --repo
{"catalog", required_argument, 0, 'c'},
+ {"provides", no_argument, 0, 0},
{"requires", no_argument, 0, 0},
+ {"conflicts", no_argument, 0, 0},
+ {"obsoletes", no_argument, 0, 0},
{"recommends", no_argument, 0, 0},
+ {"suggests", no_argument, 0, 0},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
"-r, --repo <alias|#|URI> Work only with the specified repository.\n"
"-t, --type <type> Type of package (%s).\n"
" Default: %s.\n"
- " --requires Show also requires and prerequires.\n"
- " --recommends Show also recommends."
+ " --provides Show provides.\n"
+ " --requires Show requires and prerequires.\n"
+ " --conflicts Show conflicts.\n"
+ " --obsoletes Show obsoletes.\n"
+ " --recommends Show recommends."
+ " --suggests Show suggests.\n"
), "package, patch, pattern, product", "package");
break;
}
}
- // XXX: would requires/recommends make sense for pattern etc.?
- if (copts.count("requires") || copts.count("recommends"))
- {
- if (kind != ResKind::package && kind != ResKind::patch)
- {
- out().error(boost::str(format(
- _("Type '%s' does not support %s.")) % kind % "--requires/--recommends"));
- setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS);
- return;
- }
- }
-
initRepoManager();
init_target(*this);
init_repos(*this);
extern ZYpp::Ptr God;
+///////////////////////////////////////////////////////////////////
+namespace
+{
+ inline std::string asCliOption( Dep dep_r )
+ { return dep_r.asString(); }
+
+ inline std::string asInfoTag( Dep dep_r )
+ { return dep_r.asUserString(); }
+
+ inline const std::vector<Dep> & cliSupportedDepTypes()
+ {
+ static const std::vector<Dep> _deps = {
+ Dep::PROVIDES,
+ Dep::REQUIRES,
+ Dep::CONFLICTS,
+ Dep::OBSOLETES,
+ Dep::RECOMMENDS,
+ Dep::SUGGESTS
+ };
+ return _deps;
+ }
+
+ inline void printDepList( const PoolItem & pi_r, Dep dep_r )
+ {
+ cout << asInfoTag( dep_r ) << ':' << endl;
+ for ( auto && cap : pi_r->dep( dep_r ) )
+ { cout << " " << cap << endl; }
+ }
+} // namespace out
+///////////////////////////////////////////////////////////////////
void printNVA(const ResObject::constPtr & res)
{
}
}
}
-
- if (false)
- {
- string s00 = _("None");
- string s0 = _("Requires");
- string s1 = _("Provides");
- string s2 = _("Conflicts");
- string s3 = _("Obsoletes");
- // translators: package requirements table header
- string s4 = _("Requirement");
- // translators: package requirements table header
- string s5 = _("Provided By");
- // translators: package conflicts table header
- string s6 = _("Conflict");
- }
-}
-
-static void printRequires(const PoolItem & pi)
-{
- cout << _("Requires:") << endl;
- std::list<Capability> capList = std::list<Capability>(pi->prerequires().begin(), pi->prerequires().end());
- capList.assign(pi->requires().begin(), pi->requires().end());
- for (std::list<Capability>::const_iterator it = capList.begin(); it != capList.end(); ++it)
- {
- cout << *it << endl;
- }
}
-static void printRecommends(const PoolItem & pi)
-{
- cout << _("Recommends:") << endl;
- Capabilities capSet = pi->recommends();
- for (Capabilities::const_iterator it = capSet.begin(); it != capSet.end(); ++it)
- {
- cout << *it << endl;
- }
-}
/**
* Print package information.
printSummaryDesc(theone.resolvable());
- bool requires = zypper.cOpts().count("requires");
- bool recommends = zypper.cOpts().count("recommends");
-
- if (requires)
- printRequires(theone);
-
- if (recommends)
- {
- if (requires)
- cout << endl; // visual separator
-
- printRecommends(theone);
- }
+ // Print dependency lists if CLI requests it
+ for ( auto && dep : cliSupportedDepTypes() )
+ { if ( zypper.cOpts().count( asCliOption( dep ) ) ) printDepList( theone, dep ); }
}
/**
printSummaryDesc(pool_item.resolvable());
- cout << _("Provides:") << endl;
- Capabilities capSet = pool_item.resolvable()->dep(zypp::Dep::PROVIDES);
- // WhatProvides can be used here. The result can be represented as a table of
- // a "Capability" (it->asString()) | "Provided By" (WhatProvides(c))
- for (Capabilities::const_iterator it = capSet.begin(); it != capSet.end(); ++it)
- cout << *it << endl;
-
- cout << endl << _("Conflicts:") << endl;
- capSet = pool_item.resolvable()->dep(zypp::Dep::CONFLICTS);
- for (Capabilities::const_iterator it = capSet.begin(); it != capSet.end(); ++it)
- cout << *it << endl;
-
- if (zypper.cOpts().count("requires"))
- {
- cout << endl; // visual separator
- printRequires(pool_item);
- }
-
- if (zypper.cOpts().count("recommends"))
+ // Print dependency lists if CLI requests it
+ for ( auto && dep : cliSupportedDepTypes() )
{
- cout << endl; // visual separator
- printRecommends(pool_item);
+ switch ( dep.inSwitch() )
+ {
+ case Dep::PROVIDES_e:
+ case Dep::CONFLICTS_e:
+ printDepList( pool_item, dep ); // These dependency lists are always printed
+ break;
+ default:
+ if ( zypper.cOpts().count( asCliOption( dep ) ) ) printDepList( pool_item, dep );
+ break;
+ }
}
}
if (zypper.globalOpts().is_rug_compatible)
return;
+ // Print dependency lists if CLI requests it
+ for ( auto && dep : cliSupportedDepTypes() )
+ { if ( zypper.cOpts().count( asCliOption( dep ) ) ) printDepList( pool_item, dep ); }
+
// show contents
Table t;
TableHeader th;
cout << _("Short Name") << ": " << product->shortName() << endl;
printSummaryDesc(pool_item.resolvable());
+
+ // Print dependency lists if CLI requests it
+ for ( auto && dep : cliSupportedDepTypes() )
+ { if ( zypper.cOpts().count( asCliOption( dep ) ) ) printDepList( pool_item, dep ); }
}
}