Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
pkg version -[X]s string is stupid, let's do better :)
Baptiste Daroussin committed 14 years ago
commit faac85fec181eafc539c8d5473c045a4e34ebfcf
parent 63dd3a1
3 files changed +31 -23
modified pkg/pkg-version.8
@@ -15,7 +15,7 @@
.\"     @(#)pkg.8
.\" $FreeBSD$
.\"
-
.Dd February 16, 2012
+
.Dd April 11, 2012
.Dt PKG-VERSION 8
.Os
.Sh NAME
@@ -26,10 +26,7 @@
.Op Fl hIoqv
.Op Fl l Ar limchar
.Op Fl L Ar limchar
-
.Oo
-
.Op Fl X
-
.Fl s Ar string
-
.Oc
+
.Op Fl Xxge Ar pattern
.Op Fl O Ar origin
.Op Ar index
.Nm
@@ -67,13 +64,14 @@ flag.
Displays the packages which status flag does not match the one
specified by
.Ar limchar
-
.It Fl X
-
Treat
-
.Ar string
-
as an extended regular expression.
-
.It Fl s Ar string
-
Only display the packages that match
-
.Ar string
+
.It Fl X Ar pattern
+
Only display the packages that match the extended regular expression.
+
.It Fl x Ar pattern
+
Only display the packages that match the regular expression.
+
.It Fl g Ar pattern
+
Only display the packages that match the glob expression.
+
.It Fl g Ar string
+
Only display the packages that exactly match the string.
.It Fl O Ar origin
Display only the packages which origin matches
.Ar origin
modified pkg/pkgcli.h
@@ -122,11 +122,9 @@ void usage_shell(void);
#define VERSION_VERBOSE (1<<3)
#define VERSION_STATUS (1<<4)
#define VERSION_NOSTATUS (1<<5)
-
#define VERSION_EREGEX (1<<6)
-
#define VERSION_STRING (1<<7)
-
#define VERSION_WITHORIGIN (1<<8)
-
#define VERSION_TESTVERSION (1<<9)
-
#define VERSION_TESTPATTERN (1<<10)
+
#define VERSION_WITHORIGIN (1<<7)
+
#define VERSION_TESTVERSION (1<<8)
+
#define VERSION_TESTPATTERN (1<<9)

int exec_version(int, char **);
void usage_version(void);
modified pkg/version.c
@@ -177,10 +177,12 @@ exec_version(int argc, char **argv)
	struct sbuf *res;
	const char *portsdir;
	const char *origin;
+
	match_t match = MATCH_ALL;
+
	char *pattern=NULL;

	SLIST_INIT(&indexhead);

-
	while ((ch = getopt(argc, argv, "hIoqvl:L:XsOtT")) != -1) {
+
	while ((ch = getopt(argc, argv, "hIoqvl:L:X:x:g:e:OtT")) != -1) {
		switch (ch) {
			case 'h':
				usage_version();
@@ -206,10 +208,20 @@ exec_version(int argc, char **argv)
				limchar = *optarg;
				break;
			case 'X':
-
				opt |= VERSION_EREGEX;
+
				match = MATCH_EREGEX;
+
				pattern = optarg;
				break;
-
			case 's':
-
				opt |= VERSION_STRING;
+
			case 'x':
+
				match = MATCH_REGEX;
+
				pattern = optarg;
+
				break;
+
			case 'g':
+
				match = MATCH_GLOB;
+
				pattern = optarg;
+
				break;
+
			case 'e':
+
				match = MATCH_EXACT;
+
				pattern = optarg;
				break;
			case 'O':
				opt |= VERSION_WITHORIGIN;
@@ -293,7 +305,7 @@ exec_version(int argc, char **argv)
		if (pkgdb_open(&db, PKGDB_DEFAULT) != EPKG_OK)
			return (EX_IOERR);

-
		if ((it = pkgdb_query(db, NULL, MATCH_ALL)) == NULL)
+
		if ((it = pkgdb_query(db, pattern, match)) == NULL)
			goto cleanup;

		while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC) == EPKG_OK) {
@@ -338,7 +350,7 @@ exec_version(int argc, char **argv)
		if (pkgdb_open(&db, PKGDB_DEFAULT) != EPKG_OK)
			return (EX_IOERR);

-
		if (( it = pkgdb_query(db, NULL, MATCH_ALL)) == NULL)
+
		if (( it = pkgdb_query(db, pattern, match)) == NULL)
			goto cleanup;

		while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC) == EPKG_OK) {