Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add -R option to pkg info to output the full yaml
Baptiste Daroussin committed 14 years ago
commit cd8dd1fa5f569c01fac9fff75fa6982f329a5069
parent 1b0efde
4 files changed +17 -4
modified pkg/info.c
@@ -26,7 +26,7 @@ usage_info(void)
	fprintf(stderr, "usage: pkg info <pkg-name>\n");
	fprintf(stderr, "       pkg info -a\n");
	fprintf(stderr, "       pkg info [-egxXdrlsqOf] <pkg-name>\n");
-
	fprintf(stderr, "       pkg info [-drlsqf] -F <pkg-file>\n\n");
+
	fprintf(stderr, "       pkg info [-drlsqfR] -F <pkg-file>\n\n");
	fprintf(stderr, "For more information see 'pkg help info'.\n");
}

@@ -56,7 +56,7 @@ exec_info(int argc, char **argv)
	int sign2 = 0;

	/* TODO: exclusive opts ? */
-
	while ((ch = getopt(argc, argv, "aegxXEdrlsqopOfF:")) != -1) {
+
	while ((ch = getopt(argc, argv, "aegxXEdrlsqopOfF:R")) != -1) {
		switch (ch) {
			case 'a':
				match = MATCH_ALL;
@@ -109,6 +109,10 @@ exec_info(int argc, char **argv)
			case 'F':
				file = optarg;
				break;
+
			case 'R':
+
				opt |= INFO_RAW;
+
				query_flags |= PKG_LOAD_FILES|PKG_LOAD_DIRS|PKG_LOAD_CATEGORIES|PKG_LOAD_LICENSES|PKG_LOAD_OPTIONS;
+
				break;
			default:
				usage_info();
				return(EX_USAGE);
modified pkg/pkg-info.1
@@ -27,7 +27,7 @@
.Nm
.Fl a
.Nm
-
.Op Fl egxXEdrlsqopOfF
+
.Op Fl egxXEdrlsqopOfRF
.Ar <pkg-name>
.Nm
.Op Fl drlsq
@@ -45,6 +45,9 @@ Displays all installed packages
Displays full information about the packages
matching
.Ar <pkg-name>
+
.It Fl R
+
Display the full yaml (raw) about the packages matching
+
.Ar <pkg-name>
.It Fl e
Returns 0 if
.Ar <pkg-name>
modified pkg/utils.c
@@ -38,6 +38,7 @@ print_info(struct pkg * const pkg, unsigned int opt)
	struct pkg_license *lic = NULL;
	struct pkg_option *option = NULL;
	bool multirepos_enabled = false;
+
	char *m;
	char size[7];
	const char *name, *version, *prefix, *origin, *reponame, *repourl;
	const char *maintainer, *www, *comment, *desc;
@@ -52,7 +53,11 @@ print_info(struct pkg * const pkg, unsigned int opt)
	    PKG_DESC, &desc, PKG_FLATSIZE, &flatsize, PKG_NEW_FLATSIZE, &newflatsize,
	    PKG_NEW_PKGSIZE, &newpkgsize, PKG_LICENSE_LOGIC, &licenselogic);

-
        if (opt & INFO_FULL) {
+
	if (opt & INFO_RAW) {
+
		pkg_emit_manifest(pkg, &m);
+
		printf("%s\n", m);
+
		free(m);
+
	} else if (opt & INFO_FULL) {
		printf("%-15s: %s\n", "Name", name);
		printf("%-15s: %s\n", "Version", version);
		printf("%-15s: %s\n", "Origin", origin);
modified pkg/utils.h
@@ -11,6 +11,7 @@
#define INFO_ORIGIN_SEARCH (1<<7)
#define INFO_PREFIX (1<<8)
#define INFO_FULL (1<<9)
+
#define INFO_RAW (1<<10)

bool query_yesno(const char *msg);
int print_info(struct pkg * const pkg, unsigned int opt);