mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-12 12:25:02 -05:00
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>
This commit is contained in:
parent
36f31dd133
commit
fb401f569e
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user