Author: jreidinger
Date: Tue Apr 22 15:58:56 2008
New Revision: 9786
URL: http://svn.opensuse.org/viewcvs/zypp?rev=9786&view=rev
Log:
make different output to terminal and rest
Modified:
trunk/zypper/src/output/OutNormal.cc
Modified: trunk/zypper/src/output/OutNormal.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/output/OutNormal.cc?rev=9786&r1=9785&r2=9786&view=diff
==============================================================================
--- trunk/zypper/src/output/OutNormal.cc (original)
+++ trunk/zypper/src/output/OutNormal.cc Tue Apr 22 15:58:56 2008
@@ -1,6 +1,8 @@
#include <iostream>
#include <sstream>
+#include
+
#include "zypp/Pathname.h"
#include "zypp/ByteCount.h" // for download progress reporting
#include "zypp/base/String.h" // for toUpper()
@@ -81,11 +83,16 @@
{
static AliveCursor cursor;
- cout << CLEARLN << cursor++ << " " << s;
- // dont display percents if invalid
- if (percent >= 0 && percent <= 100)
- cout << " [" << percent << "%]";
- cout << std::flush;
+ if (isatty(1))
+ {
+ cout << CLEARLN << cursor++ << " " << s;
+ // dont display percents if invalid
+ if (percent >= 0 && percent <= 100)
+ cout << " [" << percent << "%]";
+ cout << std::flush;
+ }
+ else
+ cout << '.' << std::flush;
}
// ----------------------------------------------------------------------------
@@ -94,9 +101,16 @@
{
static AliveCursor cursor;
- cursor++;
- cout << CLEARLN << cursor << " " << s;
- cout << std::flush;
+ if (isatty(1))
+ {
+ cursor++;
+ cout << CLEARLN << cursor << " " << s;
+ cout << std::flush;
+ }
+ else
+ {
+ cout << '.';
+ }
}
// ----------------------------------------------------------------------------
@@ -107,6 +121,9 @@
{
if (progressFilter())
return;
+
+ if (!isatty(1))
+ cout << label << ' ';
if (is_tick)
display_tick(id, label);
@@ -131,7 +148,10 @@
return;
static AliveCursor cursor;
- cout << CLEARLN << cursor.done() << " " << label << std::flush << endl;
+ if (isatty(1))
+ cout << CLEARLN << cursor.done() << " " << label << std::flush << endl;
+ else
+ cout << cursor.done() << std::flush << endl;
}
// progress with download rate
@@ -141,12 +161,18 @@
return;
static AliveCursor cursor;
- cout << CLEARLN << cursor << " " << _("Downloading:") << " ";
+ if (isatty(1))
+ cout << CLEARLN << cursor << " " << _("Downloading:") << " ";
+ else
+ cout << _("Downloading:") << " ";
if (verbosity() == DEBUG)
cout << uri; //! \todo shorten to fit the width of the terminal
else
cout << zypp::Pathname(uri.getPathName()).basename();
- cout << " [" << _("starting") << "]"; //! \todo align to the right
+ if (isatty(1))
+ cout << " [" << _("starting") << "]"; //! \todo align to the right
+ else
+ cout << " [" ;
cout << std::flush;
}
@@ -156,6 +182,11 @@
{
if (verbosity() < NORMAL)
return;
+ if (!isatty(1))
+ {
+ cout << '.' << std::flush;
+ return;
+ }
static AliveCursor cursor;
cout << CLEARLN << cursor++ << " " << _("Downloading:") << " ";
@@ -183,12 +214,16 @@
return;
static AliveCursor cursor;
- cout << CLEARLN << cursor.done() << " " << _("Downloading:") << " ";
- if (verbosity() == DEBUG)
- cout << uri; //! \todo shorten to fit the width of the terminal
- else
- cout << zypp::Pathname(uri.getPathName()).basename();
- cout << " [" << (error ? _("error") : _("done"));
+ if (isatty(1))
+ {
+ cout << CLEARLN << cursor.done() << " " << _("Downloading:") << " ";
+ if (verbosity() == DEBUG)
+ cout << uri; //! \todo shorten to fit the width of the terminal
+ else
+ cout << zypp::Pathname(uri.getPathName()).basename();
+ cout << " [";
+ }
+ cout << (error ? _("error") : _("done"));
if (rate >= 0)
cout << " (" << zypp::ByteCount(rate) << "/s)";
cout << "]";
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org