Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Output the number of packages to be worked on in: pkg install, upgrade, delete, autoremove
Baptiste Daroussin committed 13 years ago
commit f0ecb352c6b3eea9f9328d52a4356c8df0ec2b32
parent 025eb25
4 files changed +13 -8
modified pkg/autoremove.c
@@ -56,6 +56,7 @@ exec_autoremove(int argc, char **argv)
	int ch;
	bool yes = false;
	bool dry_run = false;
+
	int nbpkgs;

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

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

	pkg = NULL;
	if (!quiet || dry_run) {
-
		printf("Packages to be autoremoved: \n");
+
		printf("%d packages to be autoremoved: \n", nbpkgs);
		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,6 +62,7 @@ exec_delete(int argc, char **argv)
	int recursive = 0;
	bool haspkg = false;
	const char *origin;
+
	int nbpkgs;

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

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

		if (!yes)
			pkg_config_bool(PKG_CONFIG_ASSUME_ALWAYS_YES, &yes);
modified pkg/install.c
@@ -67,6 +67,7 @@ exec_install(int argc, char **argv)
	match_t match = MATCH_EXACT;
	bool force = false;
	bool dry_run = false;
+
	int nbpkgs = 0;

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

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

	/* print a summary before applying the jobs */
	pkg = NULL;
	if (!quiet || dry_run) {
		print_jobs_summary(jobs, PKG_JOBS_INSTALL,
-
		    "The following packages will be installed:\n\n");
+
		    "The following %d packages will be installed:\n\n",
+
		    nbpkgs);

		if (!yes)
			pkg_config_bool(PKG_CONFIG_ASSUME_ALWAYS_YES, &yes);
modified pkg/upgrade.c
@@ -55,6 +55,7 @@ exec_upgrade(int argc, char **argv)
	bool all = false;
	bool dry_run = false;
	bool auto_update = true;
+
	int nbpkgs;

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

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

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

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