Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Move -q from main pkg to subcommand option, add -q support to autoremove, document it.
Baptiste Daroussin committed 14 years ago
commit f453625cc6430d0966151bb09c2e7d15f8b4a73d
parent f0ac683
10 files changed +56 -35
modified pkg/autoremove.c
@@ -38,7 +38,7 @@
void
usage_autoremove(void)
{
-
	fprintf(stderr, "usage pkg autoremove [-y]\n\n");
+
	fprintf(stderr, "usage pkg autoremove [-yq]\n\n");
	fprintf(stderr, "For more information see 'pkg help autoremove'.\n");
}

@@ -56,8 +56,11 @@ exec_autoremove(int argc, char **argv)
	int ch;
	bool yes = false;

-
	while ((ch = getopt(argc, argv, "y")) != -1) {
+
	while ((ch = getopt(argc, argv, "yq")) != -1) {
		switch (ch) {
+
			case 'q':
+
				quiet = true;
+
				break;
			case 'y':
				yes = true;
				break;
@@ -115,24 +118,26 @@ exec_autoremove(int argc, char **argv)
	}

	pkg = NULL;
-
	printf("Packages to be autoremoved: \n");
-
	while (pkg_jobs(jobs, &pkg) == EPKG_OK) {
-
		const char *name, *version;
-
		pkg_get(pkg, PKG_NAME, &name, PKG_VERSION, &version);
-
		printf("\t%s-%s\n", name, version);
-
	}
+
	if (!quiet) {
+
		printf("Packages to be autoremoved: \n");
+
		while (pkg_jobs(jobs, &pkg) == EPKG_OK) {
+
			const char *name, *version;
+
			pkg_get(pkg, PKG_NAME, &name, PKG_VERSION, &version);
+
			printf("\t%s-%s\n", name, version);
+
		}

-
	if (oldsize > newsize)
-
		printf("\nThe autoremove will save %s\n", size);
-
	else
-
		printf("\nThe autoremove will require %s more space\n", size);
+
		if (oldsize > newsize)
+
			printf("\nThe autoremove will save %s\n", size);
+
		else
+
			printf("\nThe autoremove will require %s more space\n", size);

-
	if (yes == false)
-
		pkg_config_bool(PKG_CONFIG_ASSUME_ALWAYS_YES, &yes);
-
	if (yes == false)
-
		yes = query_yesno("\nProceed with autoremove of packages [y/N]: ");
+
		if (!yes)
+
			pkg_config_bool(PKG_CONFIG_ASSUME_ALWAYS_YES, &yes);
+
		if (!yes)
+
			yes = query_yesno("\nProceed with autoremove of packages [y/N]: ");
+
	}

-
	if (yes == true) {
+
	if (yes) {
		if ((retcode = pkg_jobs_apply(jobs, 1)) != EPKG_OK)
			goto cleanup;
	}
modified pkg/delete.c
@@ -39,8 +39,8 @@
void
usage_delete(void)
{
-
	fprintf(stderr, "usage: pkg delete [-ygxXfr] <pkg-name> <...>\n");
-
	fprintf(stderr, "       pkg delete [-y] -a\n\n");
+
	fprintf(stderr, "usage: pkg delete [-yqgxXfr] <pkg-name> <...>\n");
+
	fprintf(stderr, "       pkg delete [-yq] -a\n\n");
	fprintf(stderr, "For more information see 'pkg help delete'.\n");
}

@@ -78,6 +78,9 @@ exec_delete(int argc, char **argv)
			case 'f':
				force = 1;
				break;
+
			case 'q':
+
				quiet = true;
+
				break;
			case 'y':
				yes = true;
				break;
modified pkg/install.c
@@ -44,7 +44,7 @@
void
usage_install(void)
{
-
	fprintf(stderr, "usage: pkg install [-r reponame] [-yfgxX] <pkg-name> <...>\n\n");
+
	fprintf(stderr, "usage: pkg install [-r reponame] [-yqfgxX] <pkg-name> <...>\n\n");
	fprintf(stderr, "For more information see 'pkg help install'.\n");
}

@@ -65,7 +65,7 @@ exec_install(int argc, char **argv)
	match_t match = MATCH_EXACT;
	bool force = false;

-
	while ((ch = getopt(argc, argv, "yfgxXr:")) != -1) {
+
	while ((ch = getopt(argc, argv, "yfgxXr:q")) != -1) {
		switch (ch) {
			case 'y':
				yes = true;
@@ -85,6 +85,9 @@ exec_install(int argc, char **argv)
			case 'f':
				force = true;
				break;
+
			case 'q':
+
				quiet = true;
+
				break;
			default:
				usage_install();
				return (EX_USAGE);
modified pkg/main.c
@@ -90,7 +90,6 @@ usage(void)
{
	fprintf(stderr, "usage: pkg [-v] [-d] [-j <jail name or id>|-c <chroot path>] <command> [<args>]\n\n");
	fprintf(stderr, "Global options supported:\n");
-
	fprintf(stderr, "\t%-15s%s\n", "-q", "Quiet has much as possible");
	fprintf(stderr, "\t%-15s%s\n", "-d", "Increment debug level");
	fprintf(stderr, "\t%-15s%s\n", "-j", "Execute pkg(1) inside a jail(8)");
	fprintf(stderr, "\t%-15s%s\n", "-c", "Execute pkg(1) inside a chroot(8)");
@@ -178,9 +177,6 @@ main(int argc, char **argv)
				printf(PKGVERSION""GITHASH"\n");
				exit(EXIT_SUCCESS);
				break; /* NOT REACHED */
-
			case 'q':
-
				quiet = true;
-
				break;
			default:
				break;
		}
modified pkg/pkg-autoremove.8
@@ -15,7 +15,7 @@
.\"     @(#)pkg.8
.\" $FreeBSD$
.\"
-
.Dd February 16, 2012
+
.Dd March 26, 2012
.Dt PKG-AUTOREMOVE 8
.Os
.Sh NAME
@@ -23,7 +23,7 @@
.Nd removes orphan packages
.Sh SYNOPSIS
.Nm
-
.Op Fl y
+
.Op Fl yq
.Sh DESCRIPTION
.Nm
is used for removing orphan packages, which were installed
@@ -34,6 +34,8 @@ The following options are supported by
.Bl -tag -width F1
.It Fl y
Assume yes when asked for confirmation before package autoremoval.
+
.It Fl q
+
Force quiet output
.El
.Sh ENVIRONMENT
The following environment variables affect the execution of
modified pkg/pkg-delete.8
@@ -15,7 +15,7 @@
.\"     @(#)pkg.8
.\" $FreeBSD$
.\"
-
.Dd February 16, 2012
+
.Dd march 26, 2012
.Dt PKG-DELETE 8
.Os
.Sh NAME
@@ -25,7 +25,7 @@
.Nm
.Op Fl ay
.Nm
-
.Op Fl yfgxX
+
.Op Fl yqfgxX
.Ar <pkg-name> <...>
.Sh DESCRIPTION
.Nm
@@ -47,6 +47,8 @@ Treat the package names as shell glob patterns.
Treat the package names as regular expressions.
.It Fl X
Treat the package names as extended regular expressions.
+
.It Fl q
+
Force quiet output
.El
.Sh ENVIRONMENT
The following environment variables affect the execution of
modified pkg/pkg-install.8
@@ -15,7 +15,7 @@
.\"     @(#)pkg.8
.\" $FreeBSD$
.\"
-
.Dd February 16, 2012
+
.Dd March 26, 2012
.Dt PKG-INSTALL 8
.Os
.Sh NAME
@@ -23,7 +23,7 @@
.Nd installs packages from remote package repositories
.Sh SYNOPSIS
.Nm
-
.Op Fl yfgxX
+
.Op Fl yqfgxX
.Ar <pkg-origin> <...>
.Sh DESCRIPTION
.Nm
@@ -71,6 +71,8 @@ Treat the package names as regular expressions.
Treat the package names as extended regular expressions.
.It Fl f
Force the reinstallation of the package if already installed.
+
.It Fl q
+
Force quiet output.
.El
.Sh ENVIRONMENT
The following environment variables affect the execution of
modified pkg/pkg-update.8
@@ -15,7 +15,7 @@
.\"     @(#)pkg.8
.\" $FreeBSD$
.\"
-
.Dd February 16, 2012
+
.Dd March 26, 2012
.Dt PKG-UPDATE 8
.Os
.Sh NAME
@@ -23,6 +23,7 @@
.Nd updates remote package repository databases
.Sh SYNOPSIS
.Nm
+
.Op Fl q
.Sh DESCRIPTION
.Nm
is used for updating from remote package repository databases.
@@ -40,6 +41,8 @@ or upgrades via
The following options are supported by
.Nm :
.Bl -tag -width F1
+
.It Fl q
+
Force quiet output
.El
.Sh ENVIRONMENT
The following environment variables affect the execution of
modified pkg/pkg-upgrade.8
@@ -15,7 +15,7 @@
.\"     @(#)pkg.8
.\" $FreeBSD$
.\"
-
.Dd February 16, 2012
+
.Dd March 26, 2012
.Dt PKG-UPGRADE 8
.Os
.Sh NAME
@@ -43,6 +43,8 @@ The following options are supported by
Assume yes when asked for confirmation before package installation.
.It Fl f
Force reinstalling/upgrading the whole set of packages
+
.It Fl q
+
Force quiet output
.El
.Sh ENVIRONMENT
The following environment variables affect the execution of
modified pkg/upgrade.c
@@ -37,7 +37,7 @@
void
usage_upgrade(void)
{
-
	fprintf(stderr, "usage pkg upgrade [-r reponame] [-yf]\n");
+
	fprintf(stderr, "usage pkg upgrade [-r reponame] [-yfq]\n");
	fprintf(stderr, "For more information see 'pkg help upgrade'.\n");
}

@@ -62,7 +62,7 @@ exec_upgrade(int argc, char **argv)
		return (EX_NOPERM);
	}

-
	while ((ch = getopt(argc, argv, "yr:f")) != -1) {
+
	while ((ch = getopt(argc, argv, "yr:fq")) != -1) {
		switch (ch) {
			case 'y':
				yes = true;
@@ -70,6 +70,9 @@ exec_upgrade(int argc, char **argv)
			case 'r':
				reponame = optarg;
				break;
+
			case 'q':
+
				quiet = true;
+
				break;
			case 'f':
				all = true;
				break;