Author: jkupec Date: Mon Nov 26 13:51:52 2007 New Revision: 7927 URL: http://svn.opensuse.org/viewcvs/zypp?rev=7927&view=rev Log: - GlobalOptions made member of Zypper Modified: trunk/zypper/src/zypper.cc trunk/zypper/src/zypper.h Modified: trunk/zypper/src/zypper.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper.cc?rev=7927&r1=7926&r2=7927&view=diff ============================================================================== --- trunk/zypper/src/zypper.cc (original) +++ trunk/zypper/src/zypper.cc Mon Nov 26 13:51:52 2007 @@ -131,8 +131,8 @@ }; // parse global options - _gopts = parse_options (_argc, _argv, global_options); - if (gOpts().count("_unknown")) + parsed_opts gopts = parse_options (_argc, _argv, global_options); + if (gopts.count("_unknown")) { setExitCode(ZYPPER_EXIT_ERR_SYNTAX); return; @@ -156,7 +156,7 @@ parsed_opts::const_iterator it; - if (gOpts().count("rug-compatible")) + if (gopts.count("rug-compatible")) gSettings.is_rug_compatible = true; // Help is parsed by setting the help flag for a command, which may be empty @@ -165,35 +165,35 @@ // The help command is eaten and transformed to the help option // $0 help // $0 help command - if (gOpts().count("help")) + if (gopts.count("help")) setRunningHelp(true); - if (gOpts().count("quiet")) { + if (gopts.count("quiet")) { gSettings.verbosity = -1; DBG << "Verbosity " << gSettings.verbosity << endl; } - if ((it = gOpts().find("verbose")) != gOpts().end()) { + if ((it = gopts.find("verbose")) != gopts.end()) { gSettings.verbosity += it->second.size(); -// gSettings.verbosity += gOpts()["verbose"].size(); +// gSettings.verbosity += gopts["verbose"].size(); cout << format(_("Verbosity: %d")) % gSettings.verbosity << endl; DBG << "Verbosity " << gSettings.verbosity << endl; } - if (gOpts().count("non-interactive")) { + if (gopts.count("non-interactive")) { gSettings.non_interactive = true; cout_n << _("Entering non-interactive mode.") << endl; MIL << "Entering non-interactive mode" << endl; } - if (gOpts().count("no-gpg-checks")) { + if (gopts.count("no-gpg-checks")) { gSettings.no_gpg_checks = true; cout_n << _("Entering no-gpg-checks mode.") << endl; MIL << "Entering no-gpg-checks mode" << endl; } - if ((it = gOpts().find("table-style")) != gOpts().end()) { + if ((it = gopts.find("table-style")) != gopts.end()) { unsigned s; str::strtonum (it->second.front(), s); if (s < _End) @@ -202,7 +202,7 @@ cerr << _("Invalid table style ") << s << endl; } - if ((it = gOpts().find("root")) != gOpts().end()) { + if ((it = gopts.find("root")) != gopts.end()) { gSettings.root_dir = it->second.front(); Pathname tmp(gSettings.root_dir); if (!tmp.absolute()) @@ -221,15 +221,15 @@ + gSettings.rm_options.repoRawCachePath; } - if ((it = gOpts().find("reposd-dir")) != gOpts().end()) { + if ((it = gopts.find("reposd-dir")) != gopts.end()) { gSettings.rm_options.knownReposPath = it->second.front(); } - if ((it = gOpts().find("cache-dir")) != gOpts().end()) { + if ((it = gopts.find("cache-dir")) != gopts.end()) { gSettings.rm_options.repoCachePath = it->second.front(); } - if ((it = gOpts().find("raw-cache-dir")) != gOpts().end()) { + if ((it = gopts.find("raw-cache-dir")) != gopts.end()) { gSettings.rm_options.repoRawCachePath = it->second.front(); } @@ -237,15 +237,15 @@ DBG << "cache dir = " << gSettings.rm_options.repoCachePath << endl; DBG << "raw cache dir = " << gSettings.rm_options.repoRawCachePath << endl; - if (gOpts().count("terse")) + if (gopts.count("terse")) { gSettings.machine_readable = true; cout << "<?xml version='1.0'?>" << endl; cout << "<stream>" << endl; } - if (gOpts().count("disable-repositories") || - gOpts().count("disable-system-sources")) + if (gopts.count("disable-repositories") || + gopts.count("disable-system-sources")) { MIL << "Repositories disabled, using target only." << endl; cout_n << @@ -258,16 +258,16 @@ MIL << "System sources enabled" << endl; } - if (gOpts().count("disable-system-resolvables")) + if (gopts.count("disable-system-resolvables")) { MIL << "System resolvables disabled" << endl; cout_v << _("Ignoring installed resolvables...") << endl; gSettings.disable_system_resolvables = true; } /* - if (gOpts().count("source")) + if (gopts.count("source")) { - list<string> sources = gOpts()["source"]; + list<string> sources = gopts["source"]; for (list<string>::const_iterator it = sources.begin(); it != sources.end(); ++it ) { Url url = make_url (*it); @@ -279,7 +279,7 @@ } */ // testing option - if ((it = gOpts().find("opt")) != gOpts().end()) { + if ((it = gopts.find("opt")) != gopts.end()) { cout << "Opt arg: "; std::copy (it->second.begin(), it->second.end(), ostream_iterator<string> (cout, ", ")); @@ -335,7 +335,7 @@ { if (runningHelp()) cout << help_global_options << endl << help_commands; - else if (gOpts().count("version")) + else if (gopts.count("version")) cout << PACKAGE " " VERSION << endl; else { Modified: trunk/zypper/src/zypper.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper.h?rev=7927&r1=7926&r2=7927&view=diff ============================================================================== --- trunk/zypper/src/zypper.h (original) +++ trunk/zypper/src/zypper.h Mon Nov 26 13:51:52 2007 @@ -11,6 +11,49 @@ #include "zypper-command.h" #include "zypper-getopt.h" +/** + * Structure for holding global options. + */ +struct GlobalOptions +{ + GlobalOptions() + : + verbosity(0), + disable_system_sources(false), + disable_system_resolvables(false), + is_rug_compatible(false), + non_interactive(false), + no_gpg_checks(false), + license_auto_agree(false), + machine_readable(false), + root_dir("/") + {} + +// std::listzypp::Url additional_sources; + + /** + * Level of the amount of output. + * + * <ul> + * <li>-1 quiet</li> + * <li> 0 normal (default)</li> + * <li> 1 verbose</li> + * <li> 2 debug</li> + * </ul> + */ + int verbosity; + bool disable_system_sources; + bool disable_system_resolvables; + bool is_rug_compatible; + bool non_interactive; + bool no_gpg_checks; + bool license_auto_agree; // TODO move to commandOptions + bool machine_readable; + std::string root_dir; + zypp::RepoManagerOptions rm_options; +}; + + class Zypper { public: @@ -21,7 +64,7 @@ int main(int argc, char ** argv); // setters & getters - const parsed_opts & gOpts() const { return _gopts; } + const GlobalOptions & globalOpts() const { return _gopts; } const parsed_opts & cOpts() const { return _copts; } const ZypperCommand & command() const { return _command; } const std::string & commandHelp() const { return _command_help; } @@ -49,7 +92,7 @@ int _argc; char ** _argv; - parsed_opts _gopts; + GlobalOptions _gopts; parsed_opts _copts; ZypperCommand _command; std::vectorstd::string _arguments; @@ -61,48 +104,7 @@ int _sh_argc; char **_sh_argv; -}; - -/** - * Structure for holding various start-up setting. - */ -struct GlobalOptions -{ - GlobalOptions() - : - verbosity(0), - disable_system_sources(false), - disable_system_resolvables(false), - is_rug_compatible(false), - non_interactive(false), - no_gpg_checks(false), - license_auto_agree(false), - machine_readable(false), - root_dir("/") - {} - -// std::listzypp::Url additional_sources; - /** - * Level of the amount of output. - * - * <ul> - * <li>-1 quiet</li> - * <li> 0 normal (default)</li> - * <li> 1 verbose</li> - * <li> 2 debug</li> - * </ul> - */ - int verbosity; - bool disable_system_sources; - bool disable_system_resolvables; - bool is_rug_compatible; - bool non_interactive; - bool no_gpg_checks; - bool license_auto_agree; // TODO move to commandOptions - bool machine_readable; - std::string root_dir; - zypp::RepoManagerOptions rm_options; }; struct RuntimeData -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org