Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Allow the user to specify 'yes' to all prompts during install/deinstall
Marin Atanasov Nikolov committed 14 years ago
commit db9af1794b94d3ce07e57177e6f54204ee64738d
parent 4ae1de4
2 files changed +31 -10
modified pkg/delete.c
@@ -13,8 +13,8 @@
void
usage_delete(void)
{
-
	fprintf(stderr, "usage: pkg delete [-f] <pkg-name> <...>\n");
-
	fprintf(stderr, "       pkg delete -a\n\n");
+
	fprintf(stderr, "usage: pkg delete [-yf] <pkg-name> <...>\n");
+
	fprintf(stderr, "       pkg delete [-y] -a\n\n");
	fprintf(stderr, "For more information see 'pkg help delete'.\n");
}

@@ -29,9 +29,10 @@ exec_delete(int argc, char **argv)
	int i, ch;
	int flags = PKG_LOAD_BASIC;
	int force = 0;
+
	int yes = 0;
	int retcode = EPKG_OK;

-
	while ((ch = getopt(argc, argv, "af")) != -1) {
+
	while ((ch = getopt(argc, argv, "afy")) != -1) {
		switch (ch) {
			case 'a':
				match = MATCH_ALL;
@@ -39,6 +40,9 @@ exec_delete(int argc, char **argv)
			case 'f':
				force = 1;
				break;
+
			case 'y':
+
				yes = 1;
+
				break;
			default:
				usage_delete();
				return (EX_USAGE);
@@ -101,9 +105,11 @@ exec_delete(int argc, char **argv)
	while (pkg_jobs(jobs, &pkg) == EPKG_OK) 
		printf("\t%s-%s\n", pkg_get(pkg, PKG_NAME), pkg_get(pkg, PKG_VERSION));

-
	if (query_yesno("\nProceed with deinstalling packages [y/N]: ")) {
-
		pkg = NULL;
-
		if ((retcode = pkg_jobs_apply(jobs, force)) != EPKG_OK) 
+
	if (yes == 0)
+
		yes = query_yesno("\nProceed with deinstalling packages [y/N]: ");
+

+
	if (yes == 1) {
+
		if ((retcode = pkg_jobs_apply(jobs, force)) != EPKG_OK)
			goto cleanup;
	} else
		goto cleanup;
modified pkg/install.c
@@ -16,7 +16,7 @@
void
usage_install(void)
{
-
	fprintf(stderr, "usage: pkg install <pkg-name>\n");
+
	fprintf(stderr, "usage: pkg install [-y] <pkg-name> <...>\n");
	fprintf(stderr, "For more information see 'pkg help install'.\n");
}

@@ -27,7 +27,7 @@ exec_install(int argc, char **argv)
	struct pkgdb *db = NULL;
	struct pkg_jobs *jobs = NULL;
	int retcode = EPKG_OK;
-
	int i;
+
	int i, ch, yes = 0;

	if (argc < 2) {
		usage_install();
@@ -39,6 +39,18 @@ exec_install(int argc, char **argv)
		return (EX_NOPERM);
	}

+
	while ((ch = getopt(argc, argv, "y")) != -1) {
+
		switch (ch) {
+
			case 'y':
+
				yes = 1;
+
				break;
+
			default:
+
				break;
+
		}
+
	}
+
	argc -= optind;
+
	argv += optind;
+

	if (pkgdb_open(&db, PKGDB_REMOTE) != EPKG_OK) {
		return (EX_IOERR);
	}
@@ -48,7 +60,7 @@ exec_install(int argc, char **argv)
		goto cleanup;
	}

-
	for (i = 1; i < argc; i++) {
+
	for (i = 0; i < argc; i++) {
		if ((pkg = pkgdb_query_remote(db, argv[i])) == NULL) {
			retcode = EPKG_FATAL;
			goto cleanup;
@@ -64,7 +76,10 @@ exec_install(int argc, char **argv)
		printf("\t%s-%s\n", pkg_get(pkg, PKG_NAME), pkg_get(pkg, PKG_VERSION));
	}

-
	if (query_yesno("\nProceed with installing packages [y/N]: "))
+
	if (yes == 0)
+
		yes = query_yesno("\nProceed with installing packages [y/N]: ");
+

+
	if (yes == 1)
		retcode = pkg_jobs_apply(jobs, 0);

	cleanup: