From d1c85b546ae8f8ceaf9ba5962a36f6b6bae5a0a7 Mon Sep 17 00:00:00 2001 From: Tom Smeding <tom@tomsmeding.com> Date: Mon, 10 Mar 2025 18:59:40 +0100 Subject: Support listing from a different root dir --- options.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'options.c') diff --git a/options.c b/options.c index 2619602..6d43ccb 100644 --- a/options.c +++ b/options.c @@ -12,6 +12,7 @@ struct options parse_options(int argc, char **argv) { char **cachetags = malloc(cachetags_cap * sizeof(char*)); char *rootpath = NULL; + char *treeroot = NULL; int print_depth = 1; @@ -25,6 +26,20 @@ struct options parse_options(int argc, char **argv) { } rootpath = strdup(argv[i]); + } else if (strcmp(argv[i], "--treeroot") == 0) { + if (i + 1 >= argc) { + fprintf(stderr, "'--treeroot' takes an argument\n"); + exit(1); + } + + if (treeroot) { + fprintf(stderr, "Multiple tree roots given\n"); + exit(1); + } + treeroot = strdup(argv[i+1]); + + i++; + } else if (strcmp(argv[i], "--exclude") == 0) { if (i + 1 >= argc) { fprintf(stderr, "'--exclude' takes an argument\n"); @@ -89,6 +104,7 @@ struct options parse_options(int argc, char **argv) { .ncachetags = cachetags_len, .cachetags = cachetags, .rootpath = rootpath, + .treeroot = treeroot, .print_depth = print_depth, .debug = debug, }; -- cgit v1.2.3-70-g09d2