Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Long options
Matthew Seaman committed 11 years ago
commit c1af7cf881ce28978dd5bfb058c240530beaa28b
parent e721104
1 file changed +50 -28
modified src/install.c
@@ -31,6 +31,7 @@
#include <sys/types.h>

#include <err.h>
+
#include <getopt.h>
#include <libgen.h>
#include <stdbool.h>
#include <stdio.h>
@@ -53,21 +54,42 @@ usage_install(void)
int
exec_install(int argc, char **argv)
{
-
	struct pkgdb *db = NULL;
-
	struct pkg_jobs *jobs = NULL;
-
	const char *reponame = NULL;
-
	int retcode;
-
	int updcode = EPKG_OK;
-
	int ch;
-
	int mode, repo_type;
-
	int lock_type = PKGDB_LOCK_ADVISORY;
-
	bool yes, yes_arg;
-
	bool auto_update;
-
	bool local_only = false;
-
	match_t match = MATCH_EXACT;
-
	bool dry_run = false;
+
	struct pkgdb	*db = NULL;
+
	struct pkg_jobs	*jobs = NULL;
+
	const char	*reponame = NULL;
+
	int		 retcode;
+
	int		 updcode = EPKG_OK;
+
	int		 ch;
+
	int		 mode, repo_type;
+
	int		 lock_type = PKGDB_LOCK_ADVISORY;
+
	bool		 yes, yes_arg;
+
	bool		 auto_update;
+
	bool		 local_only = false;
+
	match_t		 match = MATCH_EXACT;
+
	bool		 dry_run = false;
+
	pkg_flags	 f = PKG_FLAG_NONE | PKG_FLAG_PKG_VERSION_TEST;
+

+
	struct option longopts[] = {
+
		{ "automatic",		no_argument,		NULL,	'A' },
+
		{ "case-sensitive",	no_argument,		NULL,	'C' },
+
		{ "force",		no_argument,		NULL,	'f' },
+
		{ "fetch-only",		no_argument,		NULL,	'F' },
+
		{ "glob",		no_argument,		NULL,	'g' },
+
		{ "case-insensitive",	no_argument,		NULL,	'i' },
+
		{ "no-install-scripts",	no_argument,		NULL,	'I' },
+
		{ "local-only",		no_argument,		NULL,	'l' },
+
		{ "ignore-missing",	no_argument,		NULL,	'M' },
+
		{ "dry-run",		no_argument,		NULL,	'n' },
+
		{ "quiet",		no_argument,		NULL,	'q' },
+
		{ "repository",		required_argument,	NULL,	'r' },
+
		{ "from-root",		no_argument,		NULL,   'R' },
+
		{ "no-repo-update",	no_argument,		NULL,	'U' },
+
		{ "regex",		no_argument,		NULL,	'x' },
+
		{ "yes",		no_argument,		NULL,	'y' },
+
		{ NULL,			0,			NULL,	0   },
+
	};
+

	nbactions = nbdone = 0;
-
	pkg_flags f = PKG_FLAG_NONE | PKG_FLAG_PKG_VERSION_TEST;

	yes_arg = pkg_object_bool(pkg_config_get("ASSUME_ALWAYS_YES"));
	auto_update = pkg_object_bool(pkg_config_get("REPO_AUTOUPDATE"));
@@ -86,7 +108,7 @@ exec_install(int argc, char **argv)
		quiet = true;
	}

-
	while ((ch = getopt(argc, argv, "ACfgIiFMnqRr:Uxyl")) != -1) {
+
	while ((ch = getopt_long(argc, argv, "ACfFgiIlMnqr:RUxy", longopts, NULL)) != -1) {
		switch (ch) {
		case 'A':
			f |= PKG_FLAG_AUTOMATIC;
@@ -97,20 +119,21 @@ exec_install(int argc, char **argv)
		case 'f':
			f |= PKG_FLAG_FORCE;
			break;
-
		case 'g':
-
			match = MATCH_GLOB;
-
			break;
-
		case 'I':
-
			f |= PKG_FLAG_NOSCRIPT;
-
			break;
		case 'F':
			f |= PKG_FLAG_SKIP_INSTALL;
			lock_type = PKGDB_LOCK_READONLY;
			break;
+
		case 'g':
+
			match = MATCH_GLOB;
+
			break;
		case 'i':
			pkgdb_set_case_sensitivity(false);
			break;
-
		case 'U':
+
		case 'I':
+
			f |= PKG_FLAG_NOSCRIPT;
+
			break;
+
		case 'l':
+
			local_only = true;
			auto_update = false;
			break;
		case 'M':
@@ -124,11 +147,14 @@ exec_install(int argc, char **argv)
		case 'q':
			quiet = true;
			break;
+
		case 'r':
+
			reponame = optarg;
+
			break;
		case 'R':
			f |= PKG_FLAG_RECURSIVE;
			break;
-
		case 'r':
-
			reponame = optarg;
+
		case 'U':
+
			auto_update = false;
			break;
		case 'x':
			match = MATCH_REGEX;
@@ -136,10 +162,6 @@ exec_install(int argc, char **argv)
		case 'y':
			yes_arg = true;
			break;
-
		case 'l':
-
			local_only = true;
-
			auto_update = false;
-
			break;
		default:
			usage_install();
			return (EX_USAGE);