Author: dmacvicar Date: Tue Jun 12 15:14:12 2007 New Revision: 5733 URL: http://svn.opensuse.org/viewcvs/zypp?rev=5733&view=rev Log: implement zypper sl Modified: trunk/zypper/src/zypper-sources.cc Modified: trunk/zypper/src/zypper-sources.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-sources.cc?rev=5733&r1=5732&r2=5733&view=diff ============================================================================== --- trunk/zypper/src/zypper-sources.cc (original) +++ trunk/zypper/src/zypper-sources.cc Tue Jun 12 15:14:12 2007 @@ -18,6 +18,7 @@ using namespace std; using namespace zypp; +using namespace zypp::repo; using namespace boost; extern ZYpp::Ptr God; @@ -186,19 +187,63 @@ cout << tbl; } +static void print_repo_list( const std::listzypp::RepoInfo &repos ) +{ + Table tbl; + TableHeader th; + th << "#"; + if (gSettings.is_rug_compatible) th << _("Status"); + else th << _("Enabled") << _("Refresh"); + th << _("Type") << _("Name") << "URI"; + tbl << th; + + int i = 1; + + for (std::list<RepoInfo>::const_iterator it = repos.begin(); + it != repos.end(); ++it) + { + RepoInfo repo = *it; + TableRow tr (gSettings.is_rug_compatible ? 5 : 6); + tr << str::numstring (i); + + // rug's status (active, pending => active, disabled <= enabled, disabled) + // this is probably the closest possible compatibility arrangement + if (gSettings.is_rug_compatible) + { + tr << (repo.enabled() ? _("Active") : _("Disabled")); + } + // zypper status (enabled, autorefresh) + else + { + tr << (repo.enabled() ? _("Yes") : _("No")); + tr << (repo.autorefresh() ? _("Yes") : _("No")); + } + + tr << repo.type().asString(); + tr << repo.alias(); + + std::set<Url> urls; + urls = repo.urls(); + for ( RepoInfo::urls_const_iterator uit = urls.begin(); + uit != urls.end(); + ++uit ) + { + tr << (*uit).asString(); + } + + tbl << tr; + } + cout << tbl; +} + void list_system_sources() { - std::list<SourceInfo> sources; + RepoManager manager; + std::listzypp::RepoInfo repos; - try +try { -#ifdef LIBZYPP_1xx - sources = SourceManager::sourceManager()->knownSourceInfos (gSettings.root_dir); -#else - zypp::storage::PersistentStorage store; - store.init( gSettings.root_dir ); - sources = store.storedSources(); -#endif + repos = manager.knownRepositories(); } catch ( const Exception &e ) { @@ -206,7 +251,7 @@ exit(-1); } - print_source_list(sources); + print_repo_list(repos); } bool parse_repo_file (const string& file, string& url, string& alias) -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org