- compile
authorJan Kupec <jkupec@suse.cz>
Fri, 14 Mar 2008 09:47:45 +0000 (09:47 +0000)
committerJan Kupec <jkupec@suse.cz>
Fri, 14 Mar 2008 09:47:45 +0000 (09:47 +0000)
src/output/OutNormal.cc
src/output/OutXML.cc
src/zypper-prompt.cc
src/zypper-utils.cc

index bbd167a..18b4fe2 100644 (file)
@@ -200,10 +200,11 @@ void OutNormal::prompt(PromptId id,
 {
   string option_str;
   PromptOptions::OptionList::const_iterator it;
-  if (poptions.options().begin() != poptions.end())
+  if ((it = poptions.options().begin()) != poptions.options().end())
   {
     //if (is_default) // TODO
     option_str += *it;
+    ++it;
   }
   for (;
        it != poptions.options().end(); ++it)
index d86886d..517d61c 100644 (file)
@@ -199,7 +199,7 @@ void OutXML::prompt(PromptId id,
   {
     string option = *it;
     cout << "<option";
-    if (options.defaultOpt() == i)
+    if (poptions.defaultOpt() == i)
       cout << " default=\"1\"";
     cout << " value=\"" << xml_encode(option) << "\"";
     cout << "/>" << endl;
index f3b6e8c..33b2caa 100644 (file)
@@ -16,7 +16,7 @@ using namespace boost;
 
 PromptOptions::PromptOptions(const std::string option_str, unsigned int default_opt)
 {
-  zypp::str::split(answer_hint, back_inserter(_options), "/");
+  zypp::str::split(option_str, back_inserter(_options), "/");
 
   if (_options.size() <= default_opt)
     INT << "Invalid default option index " << default_opt << endl;
@@ -41,7 +41,8 @@ int read_action_ari (PromptId pid, int default_action) {
   // the anserws must be separated by slash characters '/' and must
   // correspond to abort/retry/ignore in that order.
   // The answers should be lower case letters.
-  out.prompt(pid, _("Abort, retry, ignore?"), _("a/r/i"));
+  PromptOptions popts(_("a/r/i"), 0);
+  out.prompt(pid, _("Abort, retry, ignore?"), popts);
 
   // choose abort if no default has been specified
   if (default_action == -1) {
@@ -79,7 +80,7 @@ int read_action_ari (PromptId pid, int default_action) {
     ostringstream s;
     s << format(_("Invalid answer '%s'.")) % c << " "
       << _("Choose letter 'a', 'r', or 'i'"); 
-    out.prompt(pid, s.str(), _("a/r/i")); //! \todo remove this, handle invalid answers within the first prompt()
+    out.prompt(pid, s.str(), popts); //! \todo remove this, handle invalid answers within the first prompt()
     DBG << "invalid answer" << endl;
   }
 
@@ -95,7 +96,8 @@ bool read_bool_answer(PromptId pid, const string & question, bool default_answer
 
   string yn = string(_("yes")) + "/" + _("no");
 
-  out.prompt(pid, question, yn);
+  PromptOptions popts(yn, default_answer ? 0 : 1);
+  out.prompt(pid, question, popts);
 
   // non-interactive mode: print the answer for convenience  (only for normal
   // output) and return default
@@ -121,7 +123,7 @@ bool read_bool_answer(PromptId pid, const string & question, bool default_answer
         // The second and the third %s is the translated 'yes' and 'no' string (lowercase).
         _("Enter 'y' for '%s' or 'n' for '%s' if nothing else works for you"))
         % _("yes") % _("no");
-      out.prompt(pid, s.str(), yn); //! \todo remove this, handle invalid answers within the first prompt()
+      out.prompt(pid, s.str(), popts); //! \todo remove this, handle invalid answers within the first prompt()
     }
     c = zypp::str::getline (stm, zypp::str::TRIM);
     been_here_before = true;
index c81a37f..c29c847 100644 (file)
@@ -9,9 +9,10 @@
 #include "zypp/media/MediaManager.h"
 #include "zypp/parser/xml_escape_parser.hpp"
 
+#include "zypper.h"
 #include "zypper-main.h"
 #include "zypper-utils.h"
-//#include "zypper-callbacks.h"
+
 
 using namespace std;
 using namespace zypp;