Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2011-10-10 14:38:59 +0200
committerDan McGee <dan@archlinux.org>2011-10-10 19:09:12 -0500
commitfb401f569e2d85cf90e45deeeeb28992360d60f7 (patch)
treea5c91267e2e5b005597da88203de0488ed1e464a
parent36f31dd133a6833f641823c3e3c12b0c0edca877 (diff)
pactree: Add "--config" option
This allows for specifying an alternate configuration file path, similar to pacman's "--config" option. Given that there is currently no other way to tell pactree to read from another configuration file (except for patching or symlinking), this seems totally sensible - even if there are plans to refactor and/or replace the standalone configuration file parser. We do not define a short option for the sake of consistency with pacman's set of command line options. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--src/util/pactree.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/util/pactree.c b/src/util/pactree.c
index 09fe1011..5e98f794 100644
--- a/src/util/pactree.c
+++ b/src/util/pactree.c
@@ -76,6 +76,11 @@ static struct color_choices no_color = {
""
};
+/* long operations */
+enum {
+ OP_CONFIG = 1000
+};
+
/* globals */
alpm_handle_t *handle = NULL;
alpm_list_t *walked = NULL;
@@ -90,6 +95,7 @@ int reverse = 0;
int unique = 0;
int searchsyncs = 0;
const char *dbpath = DBPATH;
+const char *configfile = CONFFILE;
#ifndef HAVE_STRNDUP
/* A quick and dirty implementation derived from glibc */
@@ -154,7 +160,7 @@ static int register_syncs(void) {
char line[LINE_MAX];
const alpm_siglevel_t level = ALPM_SIG_DATABASE | ALPM_SIG_DATABASE_OPTIONAL;
- fp = fopen(CONFFILE, "r");
+ fp = fopen(configfile, "r");
if(!fp) {
return 1;
}
@@ -202,6 +208,8 @@ static int parse_options(int argc, char *argv[])
{"reverse", no_argument, 0, 'r'},
{"sync", no_argument, 0, 'S'},
{"unique", no_argument, 0, 'u'},
+
+ {"config", required_argument, 0, OP_CONFIG},
{0, 0, 0, 0}
};
@@ -211,6 +219,9 @@ static int parse_options(int argc, char *argv[])
}
switch(opt) {
+ case OP_CONFIG:
+ configfile = optarg;
+ break;
case 'b':
dbpath = optarg;
break;
@@ -263,11 +274,12 @@ static void usage(void)
" -c, --color colorize output\n"
" -d, --depth <#> limit the depth of recursion\n"
" -g, --graph generate output for graphviz's dot\n"
+ " -h, --help display this help message\n"
" -l, --linear enable linear output\n"
" -r, --reverse show reverse dependencies\n"
" -s, --sync search sync DBs instead of local\n"
- " -u, --unique show dependencies with no duplicates (implies -l)\n\n"
- " -h, --help display this help message\n");
+ " -u, --unique show dependencies with no duplicates (implies -l)\n"
+ " --config <path> set an alternate configuration file\n");
}
static void cleanup(void)