pkgman: cleanup output.
This makes the progressbars disappear after the download is complete, as well as reducing the number of lines for most actions to 1 instead of 3-4.
This commit is contained in:
@@ -181,6 +181,9 @@ void
|
|||||||
PackageManager::ProgressPackageDownloadActive(const char* packageName,
|
PackageManager::ProgressPackageDownloadActive(const char* packageName,
|
||||||
float completionPercentage)
|
float completionPercentage)
|
||||||
{
|
{
|
||||||
|
if (!fInteractive)
|
||||||
|
return;
|
||||||
|
|
||||||
static const char* progressChars[] = {
|
static const char* progressChars[] = {
|
||||||
"\xE2\x96\x8F",
|
"\xE2\x96\x8F",
|
||||||
"\xE2\x96\x8E",
|
"\xE2\x96\x8E",
|
||||||
@@ -201,7 +204,7 @@ PackageManager::ProgressPackageDownloadActive(const char* packageName,
|
|||||||
int ipart = (int)(completionPercentage * width);
|
int ipart = (int)(completionPercentage * width);
|
||||||
int fpart = (int)(((completionPercentage * width) - ipart) * 8);
|
int fpart = (int)(((completionPercentage * width) - ipart) * 8);
|
||||||
|
|
||||||
printf("\r"); // erase the line
|
printf("\r"); // return to the beginning of the line
|
||||||
|
|
||||||
for (position = 0; position < width; position++) {
|
for (position = 0; position < width; position++) {
|
||||||
if (position < ipart) {
|
if (position < ipart) {
|
||||||
@@ -226,21 +229,31 @@ PackageManager::ProgressPackageDownloadActive(const char* packageName,
|
|||||||
void
|
void
|
||||||
PackageManager::ProgressPackageDownloadComplete(const char* packageName)
|
PackageManager::ProgressPackageDownloadComplete(const char* packageName)
|
||||||
{
|
{
|
||||||
printf("\nFinished downloading %s.\n", packageName);
|
if (fInteractive) {
|
||||||
|
// Overwrite the progress bar with whitespace
|
||||||
|
printf("\r");
|
||||||
|
struct winsize w;
|
||||||
|
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
||||||
|
for (int i = 0; i < (w.ws_col); i++)
|
||||||
|
printf(" ");
|
||||||
|
printf("\r\x1b[1A"); // Go to previous line.
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Downloading %s...done.\n", packageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PackageManager::ProgressPackageChecksumStarted(const char* title)
|
PackageManager::ProgressPackageChecksumStarted(const char* title)
|
||||||
{
|
{
|
||||||
printf("%s...\n", title);
|
printf("%s...", title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PackageManager::ProgressPackageChecksumComplete(const char* title)
|
PackageManager::ProgressPackageChecksumComplete(const char* title)
|
||||||
{
|
{
|
||||||
printf("%s complete.\n", title);
|
printf("done.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user