Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Improve output by printing the state of actions:
Baptiste Daroussin committed 13 years ago
commit f6ad1fe3fb33141b5389470b1eb3d2d1c0605a84
parent f0ecb35
6 files changed +30 -19
modified pkg/autoremove.c
@@ -56,7 +56,7 @@ exec_autoremove(int argc, char **argv)
	int ch;
	bool yes = false;
	bool dry_run = false;
-
	int nbpkgs;
+
	nbactions = nbdone = 0;

	while ((ch = getopt(argc, argv, "ynq")) != -1) {
		switch (ch) {
@@ -118,7 +118,7 @@ exec_autoremove(int argc, char **argv)
		humanize_number(size, sizeof(size), newsize - oldsize, "B", HN_AUTOSCALE, 0);
	}

-
	if ((nbpkgs = pkg_jobs_count(jobs)) == 0) {
+
	if ((nbactions = pkg_jobs_count(jobs)) == 0) {
		printf("Nothing to do.\n");
		retcode = 0;
		goto cleanup;
@@ -126,7 +126,7 @@ exec_autoremove(int argc, char **argv)

	pkg = NULL;
	if (!quiet || dry_run) {
-
		printf("%d packages to be autoremoved: \n", nbpkgs);
+
		printf("%d packages to be autoremoved: \n", nbactions);
		while (pkg_jobs(jobs, &pkg) == EPKG_OK) {
			const char *name, *version;
			pkg_get(pkg, PKG_NAME, &name, PKG_VERSION, &version);
modified pkg/delete.c
@@ -62,7 +62,7 @@ exec_delete(int argc, char **argv)
	int recursive = 0;
	bool haspkg = false;
	const char *origin;
-
	int nbpkgs;
+
	nbactions = nbdone = 0;

	while ((ch = getopt(argc, argv, "afgnqRXxy")) != -1) {
		switch (ch) {
@@ -141,7 +141,7 @@ exec_delete(int argc, char **argv)
	}

	/* check if we have something to deinstall */
-
	if ((nbpkgs = pkg_jobs_count(jobs)) == 0) {
+
	if ((nbactions = pkg_jobs_count(jobs)) == 0) {
		if (argc == 0) {
			if (!quiet)
				printf("Nothing to do.\n");
@@ -156,7 +156,7 @@ exec_delete(int argc, char **argv)
	pkg = NULL;
	if (!quiet || dry_run) {
		print_jobs_summary(jobs, PKG_JOBS_DEINSTALL,
-
		    "The following %d packages will be deinstalled:\n\n", nbpkgs);
+
		    "The following %d packages will be deinstalled:\n\n", nbactions);

		if (!yes)
			pkg_config_bool(PKG_CONFIG_ASSUME_ALWAYS_YES, &yes);
modified pkg/event.c
@@ -91,7 +91,9 @@ event_callback(void *data, struct pkg_event *ev)
			break;
		pkg_get(ev->e_install_begin.pkg, PKG_NAME, &name,
		    PKG_VERSION, &version);
-
		printf("Installing %s-%s...", name, version);
+
		nbdone++;
+
		printf("[%d/%d] Installing %s-%s...", nbdone, nbactions,
+
		    name, version);
		break;
	case PKG_EVENT_INSTALL_FINISHED:
		if (quiet)
@@ -119,7 +121,9 @@ event_callback(void *data, struct pkg_event *ev)
			break;
		pkg_get(ev->e_deinstall_begin.pkg, PKG_NAME, &name,
		    PKG_VERSION, &version);
-
		printf("Deleting %s-%s...", name, version);
+
		nbdone++;
+
		printf("[%d/%d] Deleting %s-%s...", nbdone, nbactions,
+
		    name, version);
		break;
	case PKG_EVENT_DEINSTALL_FINISHED:
		if (quiet)
@@ -131,17 +135,22 @@ event_callback(void *data, struct pkg_event *ev)
			break;
		pkg_get(ev->e_upgrade_finished.pkg, PKG_NAME, &name,
		    PKG_VERSION, &version, PKG_NEWVERSION, &newversion);
+
		nbdone++;
		switch (pkg_version_cmp(version, newversion)) {
		case 1:
-
			printf("Downgrading %s from %s to %s...", name,
-
			    version, newversion);
+
			printf("[%d/%d] Downgrading %s from %s to %s...",
+
			    nbdone, nbactions,
+
			    name, version, newversion);
			break;
		case 0:
-
			printf("Reinstalling %s-%s", name, version);
+
			printf("[%d/%d] Reinstalling %s-%s",
+
			    nbdone, nbactions,
+
			    name, version);
			break;
		case -1:
-
			printf("Upgrading %s from %s to %s...", name,
-
			    version, newversion);
+
			printf("[%d/%d] Upgrading %s from %s to %s...",
+
			    nbdone, nbactions,
+
			    name, version, newversion);
			break;
		}
		break;
modified pkg/install.c
@@ -67,7 +67,7 @@ exec_install(int argc, char **argv)
	match_t match = MATCH_EXACT;
	bool force = false;
	bool dry_run = false;
-
	int nbpkgs = 0;
+
	nbactions = nbdone = 0;

	while ((ch = getopt(argc, argv, "AfgLnqRr:Xxy")) != -1) {
		switch (ch) {
@@ -148,7 +148,7 @@ exec_install(int argc, char **argv)
	}
	pkgdb_it_free(it);

-
	if ((nbpkgs = pkg_jobs_count(jobs)) == 0)
+
	if ((nbactions = pkg_jobs_count(jobs)) == 0)
		goto cleanup;

	/* print a summary before applying the jobs */
@@ -156,7 +156,7 @@ exec_install(int argc, char **argv)
	if (!quiet || dry_run) {
		print_jobs_summary(jobs, PKG_JOBS_INSTALL,
		    "The following %d packages will be installed:\n\n",
-
		    nbpkgs);
+
		    nbactions);

		if (!yes)
			pkg_config_bool(PKG_CONFIG_ASSUME_ALWAYS_YES, &yes);
modified pkg/pkgcli.h
@@ -28,6 +28,8 @@
#define _PKGCLI_H

extern bool quiet;
+
int nbactions;
+
int nbdone;

/* pkg add */
int exec_add(int, char **);
modified pkg/upgrade.c
@@ -55,7 +55,7 @@ exec_upgrade(int argc, char **argv)
	bool all = false;
	bool dry_run = false;
	bool auto_update = true;
-
	int nbpkgs;
+
	nbactions = nbdone = 0;

	while ((ch = getopt(argc, argv, "fLnqr:y")) != -1) {
		switch (ch) {
@@ -120,7 +120,7 @@ exec_upgrade(int argc, char **argv)
	}
	pkgdb_it_free(it);

-
	if ((nbpkgs = pkg_jobs_count(jobs)) == 0) {
+
	if ((nbactions = pkg_jobs_count(jobs)) == 0) {
		if (!quiet)
			printf("Nothing to do\n");
		retcode = EXIT_SUCCESS;
@@ -129,7 +129,7 @@ exec_upgrade(int argc, char **argv)

	pkg = NULL;
	if (!quiet || dry_run) {
-
		print_jobs_summary(jobs, PKG_JOBS_INSTALL, "The following %d packages will be upgraded:\n\n", nbpkgs);
+
		print_jobs_summary(jobs, PKG_JOBS_INSTALL, "The following %d packages will be upgraded:\n\n", nbactions);

		if (!yes)
			pkg_config_bool(PKG_CONFIG_ASSUME_ALWAYS_YES, &yes);