src/cline.c

changeset 90
9b541d22d649
parent 89
c80878da618c
--- a/src/cline.c	Sun Jun 28 14:29:39 2026 +0200
+++ b/src/cline.c	Sun Jun 28 15:57:44 2026 +0200
@@ -45,6 +45,8 @@
     "\n                        One of: ignore low medium high"
     "\n  -c                  - Count non-whitespace characters instead of lines"
     "\n  -d                  - Report only directory sums"
+    "\n  -D <path>           - Excludes the directory at the specified <path>"
+    "\n  -D <name>           - Excludes all directories with the given <name>"
     "\n  -E <pattern>        - Excludes any line matching the <pattern>"
     "\n  -e <start> <end>    - Excludes lines between <start> and <end>"
     "\n                        You may use these options multiple times"
@@ -116,7 +118,7 @@
 
   for (int t = 1 ; t < argc ; t++) {
 
-    int argflags = checkArgument(argv[t], "hsSrRmvVbeEicd");
+    int argflags = checkArgument(argv[t], "hsSrRmvVbeEicdD");
     int paropt = 0;
 
     /* h */
@@ -234,6 +236,16 @@
         settings->dirsOnly = true;
       }
     }
+    /* D */
+    if ((argflags & 16384) > 0) {
+      t++;
+      if (!checkParamOpt(&paropt) || t >= argc) {
+        return exit_with_help(settings, 1);
+      }
+      // TODO: normalize argument before adding to dir list
+      //       this makes it more efficient to compare dir names later
+      add_string(settings->excludeDirs, argv[t]);
+    }
     if (argflags == 0) {
       /* SHORTCUTS */
       if (strcmp(argv[t], "--exclude-cstyle-comments") == 0) {

mercurial