summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <d@falconindy.com>2010-11-30 22:44:05 -0500
committerDave Reisner <d@falconindy.com>2010-11-30 22:58:13 -0500
commitd35f8eb3d74f54f9ae146d6d17c2097705540ddf (patch)
tree74c9da3e4ecee2d4fdcb98b38be2fbddbb87f3e9
parent4b61b317b7e1fc4920d9551cbe3be951f04635d1 (diff)
downloadexpac-d35f8eb3d74f54f9ae146d6d17c2097705540ddf.tar.xz
add install reason as %w
also, declare another global 'local' so we know when we're only parsing locally or not.
-rw-r--r--README.pod4
-rw-r--r--expac.c8
2 files changed, 10 insertions, 2 deletions
diff --git a/README.pod b/README.pod
index e3d2ca8..2f89272 100644
--- a/README.pod
+++ b/README.pod
@@ -95,7 +95,7 @@ The format argument allows the following interpreted sequences:
%f filename (only with -S)
- %i has install scriptlet
+ %i has install scriptlet (only with -Q)
%k download size
@@ -115,6 +115,8 @@ The format argument allows the following interpreted sequences:
%v version
+ %w install reason
+
%% literal %
Standard backslash escape sequences are supported. See printf(1).
diff --git a/expac.c b/expac.c
index 57c391a..04a9450 100644
--- a/expac.c
+++ b/expac.c
@@ -34,13 +34,14 @@
#include <stdlib.h>
#include <string.h>
-#define FORMAT_TOKENS "BCDEFGLNOPRSabdfiklmnprsuv%"
+#define FORMAT_TOKENS "BCDEFGLNOPRSabdfiklmnprsuvw%"
#define ESCAPE_TOKENS "\"\\abefnrtv"
alpm_list_t *dblist = NULL, *targets = NULL;
pmdb_t *db_local;
bool verbose = false;
bool search = false;
+bool local = false;
const char *format = NULL;
const char *timefmt = NULL;
const char *listdelim = NULL;
@@ -197,6 +198,7 @@ static int parse_options(int argc, char *argv[]) {
return(1);
}
dblist = alpm_list_add(dblist, db_local);
+ local = true;
break;
case 'd':
delim = optarg;
@@ -373,6 +375,9 @@ static int print_pkg(pmpkg_t *pkg, const char *format) {
case 'r': /* repo */
out += printf("%s", alpm_db_get_name(alpm_pkg_get_db(pkg)));
break;
+ case 'w': /* install reason */
+ out += printf("%s", alpm_pkg_get_reason(pkg) ? "dependency" : "explicit");
+ break;
/* times */
case 'b': /* build date */
@@ -529,6 +534,7 @@ int main(int argc, char *argv[]) {
/* ensure sane defaults */
if (!dblist) {
+ local = true;
dblist = alpm_list_add(dblist, db_local);
}
delim = delim ? delim : "\n";