From: Michael Andres Date: Tue, 2 Aug 2011 12:08:26 +0000 (+0200) Subject: Add '-v' option to DumpSelectable tool. X-Git-Tag: 9.10.0~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9a67ccafb8a1fd532baa8a268612fbd7db994e2c;p=platform%2Fupstream%2Flibzypp.git Add '-v' option to DumpSelectable tool. --- diff --git a/tools/DumpSelectable.cc b/tools/DumpSelectable.cc index 60b2402..070201e 100644 --- a/tools/DumpSelectable.cc +++ b/tools/DumpSelectable.cc @@ -4,6 +4,7 @@ #include #include +#include static std::string appname( "DumpSelectable" ); @@ -30,10 +31,23 @@ int usage( const std::string & msg_r = std::string(), int exit_r = 100 ) cerr << " Selectables names NAME" << endl; cerr << " --root Load repos from the system located below ROOTDIR. If ROOTDIR" << endl; cerr << " denotes a sover testcase, the testcase is loaded." << endl; + cerr << " -v Verbose list solvables data." << endl; cerr << "" << endl; return exit_r; } +void dumpPi( std::ostream & message, const PoolItem & pi ) +{ + std::string indent(" "); + message << indent << "--------------------------------------------------" << endl; + message << indent << (pi->isSystem() ? "i " : "a ") << pi->satSolvable().asString() << endl; + message << indent << pi->summary() << endl; + if ( pi->isKind() ) + { + message << indent << pi->asKind()->changelog() << endl; + } +} + /****************************************************************** ** ** FUNCTION NAME : main @@ -45,6 +59,30 @@ int main( int argc, char * argv[] ) appname = Pathname::basename( argv[0] ); --argc,++argv; + Pathname sysRoot("/"); + bool verbose = false; + + while ( argc && (*argv)[0] == '-' ) + { + if ( (*argv) == std::string("--root") ) + { + --argc,++argv; + if ( ! argc ) + return errexit("--root requires an argument."); + + if ( ! PathInfo( *argv ).isDir() ) + return errexit("--root requires a directory."); + + sysRoot = *argv; + } + else if ( (*argv) == std::string("-v") ) + { + verbose = true; + } + + --argc,++argv; + } + if ( ! argc ) { return usage(); @@ -53,22 +91,8 @@ int main( int argc, char * argv[] ) /////////////////////////////////////////////////////////////////// ZConfig::instance(); - Pathname sysRoot("/"); sat::Pool satpool( sat::Pool::instance() ); - if ( (*argv) == std::string("--root") ) - { - --argc,++argv; - if ( ! argc ) - return errexit("--root requires an argument."); - - if ( ! PathInfo( *argv ).isDir() ) - return errexit("--root requires a directory."); - - sysRoot = *argv; - --argc,++argv; - } - if ( TestSetup::isTestcase( sysRoot ) ) { message << str::form( "*** Load Testcase from '%s'", sysRoot.c_str() ) << endl; @@ -130,7 +154,15 @@ int main( int argc, char * argv[] ) for ( ; argc; --argc,++argv ) { - message << dump( ui::Selectable::get( IdString( *argv ) ) ) << endl; + ui::Selectable::Ptr sel( ui::Selectable::get( IdString( *argv ) ) ); + message << dump( sel ) << endl; + if ( verbose ) + { + for_( it, sel->installedBegin(), sel->installedEnd() ) + dumpPi( message, *it ); + for_( it, sel->availableBegin(), sel->availableEnd() ) + dumpPi( message, *it ); + } } INT << "===[END]============================================" << endl << endl;